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

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

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

問題描述

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

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?).

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

...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).

我應(yīng)該指出我在談?wù)撐锢肀砼c臨時表.有很多關(guān)于臨時表與表變量的信息,例如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.

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

您的另一種方法:創(chuàng)建然后刪除常規(guī)表只會產(chǎn)生相同的開銷.

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

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

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).

我建議您重新考慮您的處理策略.一些替代方法就像使用相關(guān)查詢、派生表或表變量一樣簡單.看看: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

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

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.

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

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

相關(guān)文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個子標(biāo)記轉(zhuǎn)換為具有多個分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個表創(chuàng)建視圖?)
Create calculated value based on calculated value inside previous row(根據(jù)前一行內(nèi)的計算值創(chuàng)建計算值)
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屋-程序員軟件開發(fā)技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉(zhuǎn)換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 99精品国自产在线 | 久久久久久久久久久91 | 午夜精品久久久久久久久久久久久 | 国产精品久久久久久久久久久久午夜片 | 剑来高清在线观看 | 亚洲视频精品 | 亚洲精品久久久久久久久久久久久 | 91影片| 在线中文字幕视频 | 精品国产乱码久久久久久老虎 | 一级毛片观看 | 日日夜夜精品视频 | 国产视频第一页 | 日韩欧美视频在线 | 午夜一区二区三区在线观看 | 在线不卡| 成人免费共享视频 | 国产区精品在线观看 | 日韩三区 | 亚洲欧美一区二区三区国产精品 | 欧美日韩中文字幕 | 区一区二区三在线观看 | 久久777| 一区二区三区视频 | 在线视频中文字幕 | 中文字幕爱爱视频 | 国产精品激情在线 | 免费观看一级特黄欧美大片 | 我想看国产一级毛片 | 中文字幕亚洲欧美日韩在线不卡 | 亚洲精品视频在线看 | 国产视频福利一区 | 国产中文字幕在线观看 | 色综合激情 | 久久国产精品免费视频 | 国产成人精品一区二区 | 先锋资源站| 成人精品在线视频 | 日本视频中文字幕 | 欧美日韩综合视频 | 99久久久无码国产精品 |