pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

如何將我選擇的所有列放入虛擬變量中?

How to put all my selected columns into a dummy variable?(如何將我選擇的所有列放入虛擬變量中?)
本文介紹了如何將我選擇的所有列放入虛擬變量中?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時(shí)送ChatGPT賬號(hào)..

這個(gè)問題是的后續(xù)上一個(gè)問題.為了給您提供上下文,我想總結(jié)一下上一個(gè)問題:在上一個(gè)問題中,我打算采用一種方法來執(zhí)行選擇而不將結(jié)果發(fā)送給客戶端.目標(biāo)是通過發(fā)送數(shù)百萬數(shù)據(jù)來衡量性能而不消耗大量資源.我只對(duì)執(zhí)行這些查詢所需的時(shí)間感興趣,而不對(duì)它們將結(jié)果發(fā)送到客戶端應(yīng)用程序的時(shí)間感興趣,因?yàn)槲掖蛩銉?yōu)化查詢,所以查詢的結(jié)果根本不會(huì)改變,但方法論會(huì)改變,我打算能夠比較這些方法.

This question is a follow-up to a previous question. To give you context here as well, I would like to summarize the previous question: in my previous question I intended to have a methodology to execute selections without sending their result to the client. The goal was to measure performance without eating up a lot of resources by sending millions of data. I am only interested in the time needed to execute those queries and not in the time they will send the results to the client app, since I intend to optimize queries, so the results of the queries will not change at all, but the methodology will change and I intend to be able to compare the methodologies.

在我的另一個(gè)問題中,提出了幾個(gè)想法.一個(gè)想法是選擇記錄的計(jì)數(shù)并將其放入變量中.但是,這顯著改變了查詢計(jì)劃,結(jié)果在性能方面并不準(zhǔn)確.也提出了使用臨時(shí)表的想法,但是如果我們不知道什么查詢將是我們要測(cè)量的輸入并且還會(huì)引入很多白噪聲,那么創(chuàng)建一個(gè)臨時(shí)表并將其插入是很困難的,因此,即使想法很有創(chuàng)意,但對(duì)我的問題并不理想.最后,Vladimir Baranov 提出了一個(gè)想法,即創(chuàng)建與選擇將返回的列一樣多的變量.這是一個(gè)好主意,但我通過創(chuàng)建 nvarchar(max) 的單個(gè)變量并將我的所有列選擇到其中來進(jìn)一步完善它.這個(gè)想法很好,除了一些問題.我有大部分問題的解決方案,但我想分享它們,所以,我會(huì)描述它們,但不要誤解我,我有一個(gè)問題.

In my other question several ideas were presented. An idea was to select the count of the records and put it into a variable. However, that changed the query plan significantly and the results were not accurate in terms of performance. The idea of using a temporary table was presented as well, but creating a temporary table and inserting into it is difficult if we do not know what query will be our input to measure and also introduces a lot of white noise, so, even though the idea was creative, it was not ideal for my problem. Finally Vladimir Baranov came with an idea to create as many variables as many columns the selection will return. This was a great idea, but I refined it further, by creating a single variable of nvarchar(max) and selecting all my columns into it. The idea works great, except for a few problems. I have the solution for most of the problems, but I would like to share them, so, I will describe them regardless, but do not misunderstand me, I have a single question.

如果我有一個(gè) @container 變量并且我在每個(gè)選擇中都做了一個(gè) @container = columnname,那么我就會(huì)遇到轉(zhuǎn)換問題.

If I have a @container variable and I do a @container = columnname inside each selection, then I will have conversion problems.

我需要做一個(gè) @container = cast(columnname as nvarchar(max))

我需要轉(zhuǎn)換as something@container = cast(<whatever> as nvarchar(max)) 對(duì)于選擇中的每一列,但不是子選擇,我需要有一個(gè)通用的解決方案處理case when 和括號(hào),我不想在任何地方有 @container = 的任何實(shí)例,除了主要選擇的左側(cè).

I will need to convert <whatever> as something into @container = cast(<whatever> as nvarchar(max)) for each columns in the selection, but not for subselections and I will need to have a general solution handling case when and parantheses, I do not want to have any instances of @container = anywhere, except to the left of the main selection.

由于我對(duì)正則表達(dá)式一無所知,我可以通過迭代查詢字符串來解決這個(gè)問題,直到找到主查詢的 from 并且每次找到括號(hào)時(shí),我什么都不做,直到找到括號(hào)關(guān)閉,找到應(yīng)該放置 @container =as [customname] 的索引,并從右到左在查詢字符串中執(zhí)行所有操作.這將是一個(gè)又長(zhǎng)又不優(yōu)雅的代碼.

Since I am clueless about regular expressions, I can solve this by iterating the query string until I find the from of the main query and each time I find a parantheses, I will do nothing until that parantheses is closed, find the indexes where @container = should be put and as [customname] should be taken out and from right to left do all that in the query string. This will be a long and unelegant code.

是否可以確保我的所有主要列都以 @container = 開頭并以 as [Customname] 結(jié)尾?

Is it possible to make sure that all my main columns but nothing else start with @container = and ends without as [Customname]?

推薦答案

我會(huì)嘗試編寫一個(gè)單獨(dú)的 CLR 函數(shù),該函數(shù)根據(jù)測(cè)量需要運(yùn)行盡可能多的查詢.它可能有一個(gè)參數(shù),其中包含要運(yùn)行的查詢文本或要運(yùn)行的存儲(chǔ)過程的名稱.

I would try to write a single CLR function that runs as many queries as needed to measure. It may have a parameter with the text(s) of queries to run, or names of stored procedures to run.

您對(duì)服務(wù)器有一個(gè)請(qǐng)求.一切都在服務(wù)器上本地完成.沒有網(wǎng)絡(luò)開銷.您可以通過對(duì)需要測(cè)量的每個(gè)查詢使用 ExecuteNonQuery 來丟棄 .NET CLR 代碼中的查詢結(jié)果,而不使用顯式臨時(shí)表.

You have a single request to the server. Everything is done locally on the server. No network overhead. You discard query result in the .NET CLR code without using explicit temp tables by using ExecuteNonQuery for each query that you need to measure.

不要更改您正在衡量的查詢.優(yōu)化器很復(fù)雜,對(duì)查詢的更改可能會(huì)對(duì)性能產(chǎn)生各種影響.

Don't change the query that you are measuring. Optimizer is complex, changes to the query may have various effects on the performance.

另外,使用SET STATISTICS TIME ON讓服務(wù)器為你測(cè)量時(shí)間.獲取服務(wù)器要說的內(nèi)容,對(duì)其進(jìn)行解析并以適合您的格式將其發(fā)送回.

Also, use SET STATISTICS TIME ON and let the server measure the time for you. Fetch what the server has to say, parse it and send it back in the format that suits you.

我認(rèn)為,SET STATISTICS TIME ON/OFF 的結(jié)果是最可靠和準(zhǔn)確的,并且噪音最小.

I think, that results of SET STATISTICS TIME ON / OFF are the most reliable and accurate and have the least amount of noise.

這篇關(guān)于如何將我選擇的所有列放入虛擬變量中?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

What SQL Server Datatype Should I Use To Store A Byte[](我應(yīng)該使用什么 SQL Server 數(shù)據(jù)類型來存儲(chǔ)字節(jié) [])
Interpreting type codes in sys.objects in SQL Server(解釋 SQL Server 中 sys.objects 中的類型代碼)
Typeorm .loadRelationCountAndMap returns zeros(Typeorm .loadRelationCountAndMap 返回零)
MS SQL: Should ISDATE() Return quot;1quot; when Cannot Cast as Date?(MS SQL:ISDATE() 是否應(yīng)該返回“1?什么時(shí)候不能投射為日期?)
Converting the name of a day to its integer representation(將一天的名稱轉(zhuǎn)換為其整數(shù)表示)
How to convert nvarchar m/d/yy to mm/dd/yyyy in SQL Server?(如何在 SQL Server 中將 nvarchar m/d/yy 轉(zhuǎn)換為 mm/dd/yyyy?)
主站蜘蛛池模板: 污水处理设备维修_污水处理工程改造_机械格栅_过滤设备_气浮设备_刮吸泥机_污泥浓缩罐_污水处理设备_污水处理工程-北京龙泉新禹科技有限公司 | PC阳光板-PC耐力板-阳光板雨棚-耐力板雨棚,厂家定制[优尼科板材] | 高铝砖-高铝耐火球-高铝耐火砖生产厂家-价格【荣盛耐材】 | 塑料瓶罐_食品塑料瓶_保健品塑料瓶_调味品塑料瓶–东莞市富慷塑料制品有限公司 | 安徽合肥项目申报咨询公司_安徽合肥高新企业项目申报_安徽省科技项目申报代理 | 硅PU球场、篮球场地面施工「水性、环保、弹性」硅PU材料生产厂家-广东中星体育公司 | 优宝-汽车润滑脂-轴承润滑脂-高温齿轮润滑油脂厂家 | 整车VOC采样环境舱-甲醛VOC预处理舱-多舱法VOC检测环境仓-上海科绿特科技仪器有限公司 | 行星搅拌机,双行星搅拌机,动力混合机,无锡米克斯行星搅拌机生产厂家 | 聚氨酯保温钢管_聚氨酯直埋保温管道_聚氨酯发泡保温管厂家-沧州万荣防腐保温管道有限公司 | 阴离子_阳离子聚丙烯酰胺厂家_聚合氯化铝价格_水处理絮凝剂_巩义市江源净水材料有限公司 | arch电源_SINPRO_开关电源_模块电源_医疗电源-东佑源 | 安全,主动,被动,柔性,山体滑坡,sns,钢丝绳,边坡,防护网,护栏网,围栏,栏杆,栅栏,厂家 - 护栏网防护网生产厂家 | 生物制药洁净车间-GMP车间净化工程-食品净化厂房-杭州波涛净化设备工程有限公司 | 999范文网_优质范文下载写作帮手 | 硅胶管挤出机厂家_硅胶挤出机生产线_硅胶条挤出机_臣泽智能装备 贵州科比特-防雷公司厂家提供贵州防雷工程,防雷检测,防雷接地,防雷设备价格,防雷产品报价服务-贵州防雷检测公司 | 水上浮桥-游艇码头-浮动码头-游船码头-码瑞纳游艇码头工程 | 拖链电缆_柔性电缆_伺服电缆_坦克链电缆-深圳市顺电工业电缆有限公司 | 变位机,焊接变位机,焊接变位器,小型变位机,小型焊接变位机-济南上弘机电设备有限公司 | 转子泵_凸轮泵_凸轮转子泵厂家-青岛罗德通用机械设备有限公司 | 加热制冷恒温循环器-加热制冷循环油浴-杭州庚雨仪器有限公司 | 上海电子秤厂家,电子秤厂家价格,上海吊秤厂家,吊秤供应价格-上海佳宜电子科技有限公司 | 成都竞价托管_抖音代运营_网站建设_成都SEM外包-成都智网创联网络科技有限公司 | 河南包装袋厂家_河南真空袋批发价格_河南服装袋定制-恒源达包装制品 | 淄博不锈钢无缝管,淄博不锈钢管-鑫门物资有限公司 | 注塑模具_塑料模具_塑胶模具_范仕达【官网】_东莞模具设计与制造加工厂家 | 天空彩票天下彩,天空彩天空彩票免费资料,天空彩票与你同行开奖,天下彩正版资料大全 | 工业CT-无锡璟能智能仪器有限公司 | 成都装修公司-成都装修设计公司推荐-成都朗煜装饰公司 | 冷却塔风机厂家_静音冷却塔风机_冷却塔电机维修更换维修-广东特菱节能空调设备有限公司 | 北京四合院出租,北京四合院出售,北京平房买卖 - 顺益兴四合院 | 伶俐嫂培训学校_月嫂培训班在哪里报名学费是多少_月嫂免费政府培训中心推荐 | 二手色谱仪器,十万分之一分析天平,蒸发光检测器,电位滴定仪-湖北捷岛科学仪器有限公司 | 高压贴片电容|贴片安规电容|三端滤波器|风华电容代理南京南山 | 金属回收_废铜废铁回收_边角料回收_废不锈钢回收_废旧电缆线回收-广东益夫金属回收公司 | 玉米深加工设备|玉米加工机械|玉米加工设备|玉米深加工机械-河南成立粮油机械有限公司 | 播音主持培训-中影人教育播音主持学苑「官网」-中国艺考界的贵族学校 | 废气处理_废气处理设备_工业废气处理_江苏龙泰环保设备制造有限公司 | 深圳活动策划公司|庆典策划|专业公关活动策划|深圳艺典文化传媒 重庆中专|职高|技校招生-重庆中专招生网 | 菲希尔X射线测厚仪-菲希尔库伦法测厚仪-无锡骏展仪器有限责任公司 | 柔性测斜仪_滑动测斜仪-广州杰芯科技有限公司 |