久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

SQL中臨時表與物理表的比較速度是多少?

What is the comparative speed of temporary tables to physical tables in SQL?(SQL中臨時表與物理表的比較速度是多少?)
本文介紹了SQL中臨時表與物理表的比較速度是多少?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個腳本需要臨時提取數據以對其進行額外操作,但在腳本運行后不需要進一步存儲它.我目前在一系列臨時本地表 (CREATE TABLE #table) 中有相關數據,然后在使用完成后將其刪除.我正在考慮切換到以相同方式處理的物理表(CREATE TABLE 表),如果它的腳本速度會有所提高(或者其他優勢,也許?).

I have a script that needs to extract data temporarily to do extra operations on it, but then doesn't need to store it any further after the script has run. I currently have the data in question in a series of temporary local tables (CREATE TABLE #table), which are then dropped as their use is completed. I was considering switching to physical tables, treated in the same way (CREATE TABLE table), if there would be an improvement in the speed of the script for it (or other advantages, maybe?).

...那么,臨時表和物理表在性能上有區別嗎?從我讀到的內容來看,臨時表只是物理表,只有運行腳本的會話才能查看(減少鎖定問題).

...So, is there a difference in performance, between temporary tables and physical tables? From what I'm reading, temporary tables are just physical tables that only the session running the script can look at (cutting down on locking issues).

我應該指出我在談論物理表與臨時表.有很多關于臨時表與表變量的信息,例如http://sqlnerd.blogspot.com/2005/09/temp-tables-vs-table-variables.html.

I should point out that I'm talking about physical tables vs. temporary tables. There is a lot of info available about temporary tables vs. table variables, e.g. http://sqlnerd.blogspot.com/2005/09/temp-tables-vs-table-variables.html.

推薦答案

臨時表是 SQL Server 中的一個大問題.

Temporary tables are a big NO in SQL Server.

  • 它們會導致成本高昂的查詢計劃重新編譯.
  • 創建和刪除表也是您添加到流程中的成本高昂的操作.
  • 如果有大量數據進入臨時數據,您的操作將因缺乏索引而變慢.您可以在臨時表上創建索引.但我永遠不會為任何有大量記錄的東西推薦一個臨時表.

您的另一種方法:創建然后刪除常規表只會產生相同的開銷.

Your other approach: To create and then drop regular tables just creates the same overhead.

另一種方法:使用現有表,用附加列擴充行以區分可以使用與每個用戶/會話相關的行.消除了創建/刪除表的負擔,但是,您將需要對生成值以區分行的代碼保持偏執,并且您必須開發一種方法來維護會話過早結束的情況下的表并且還有剩余部分(處理結束時未刪除的行).

Another approach: Using existing tables, augmenting the rows with an additional column to differentiate which rows pertain to each user/session could be used. Removes the burden to create/drop the tables but, then, you will need to be paranoid with the code that generate the value to differentiate the rows AND you will have to develop a way to maintain the table for those cases where a session ended prematurely and there are leftovers (rows that were not removed at the end of the processing).

我建議您重新考慮您的處理策略.一些替代方法就像使用相關查詢、派生表或表變量一樣簡單.看看:http://www.sql-server-performance.com/articles/per/temp_tables_vs_variables_p1.aspx

I recommend you to rethink your processing strategy. Some alternatives are as easy as using correlated queries, derived tables or table variables. Take a look at: http://www.sql-server-performance.com/articles/per/temp_tables_vs_variables_p1.aspx

創建和刪除常規表的方法以及重用帶有附加字段的常規表的方法:兩者都會生成查詢計劃重新編譯,因為更改的數據量將觸發重新評估表統計信息.同樣,您最好的方法是尋找其他方法來處理您的數據.

The approach of creating and dropping regular tables and the approach of reusing a regular table augumented with an additional field: Both will generate query plan recompilations because the amount of data changed will trigger the reevaluation of table statistics. Again, your best approach is to find alternate ways to proccess your data.

這篇關于SQL中臨時表與物理表的比較速度是多少?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個子標記轉換為具有多個分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個表創建視圖?)
Create calculated value based on calculated value inside previous row(根據前一行內的計算值創建計算值)
How do I stack the first two columns of a table into a single column, but also pair third column with the first column only?(如何將表格的前兩列堆疊成一列,但也僅將第三列與第一列配對?) - IT屋-程序員軟件開發技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 国产福利小视频 | 欧美a免费| 欧美一级片在线观看 | 一区二区av | 成人免费在线观看 | 亚洲国产精品久久久久婷婷老年 | 国产高清视频在线 | 一区二区三区视频在线 | 免费观看色 | 91动漫在线观看 | 色综合久 | 国产精品日韩高清伦字幕搜索 | 久久久精品 | 午夜影院 | 国产精品成人一区二区三区 | 免费高清av| 欧洲尺码日本国产精品 | 888久久久 | 欧美一级片在线看 | 国产精品美女久久久 | 亚洲综合在线网 | 精久久久久 | 久久久久久99| 久草精品视频 | 亚洲综合国产 | 国产精品色哟哟网站 | 亚洲第一在线 | 久久亚洲精品国产精品紫薇 | 国产精品爱久久久久久久 | 99re热精品视频 | 综合中文字幕 | 欧美亚洲高清 | 国产美女在线观看 | 欧美高清视频一区 | 亚洲精品一区二区三区在线 | 久久久久国产精品午夜一区 | 国产成人久久精品一区二区三区 | 日日操操 | 欧美 日韩 在线播放 | 成人国产一区二区三区精品麻豆 | 亚洲午夜精品在线观看 |