sqlperformance

Is there any good ways to improve the parser's performance generated using antlr4?

旧时模样 提交于 2019-12-11 16:28:00
问题 I have tried a few days to fix my grammar file(uniformSQL.g4) in order to improve the parser performance but still failed. The parser cost 4000+ ms to parser through the SQL case. And I also tried to use SLL(*) strategy, it is fast but come out a lot of mismatch cases. So I wonder how to get the best performance when designing the grammar. I also tried to lower the parse tree'height when designing grammar, but the speed turned out to be slower. Looking forward to your suggestion,thanks. This

Are Columns Not Selected in SQL Views Executed?

你。 提交于 2019-12-11 03:54:49
问题 I wasn't able to come up with the right keywords to search for the answer for this, so apologies if it was answered already. Consider the following SQL view: CREATE VIEW View1 AS SELECT Column1 ,Column2 ,(SELECT SUM(Column3) FROM Table2 WHERE Table2.ID = Table1.ID) -- Subquery FROM Table1 If I run the following query, will the subquery be executed or does SQL Server optimise the query? SELECT Column1 FROM View1 I'm looking at this from a performance point of view, say, if the view has quite a

SQL Server : Geography search performance - query nearest stores

萝らか妹 提交于 2019-12-10 13:53:27
问题 I have a performance query nearest stores: We have a table that contains around 50,000 records (stores/point of sale locations) in one country. Each record has location columns of type "geography" [LOCATION_geo] [geography] Also for performance I created a SPATIAL INDEX over that location column using this syntax CREATE SPATIAL INDEX [LOCATION_geoIndex] ON [dbo].[StoreLocations] ([LOCATION_geo]) USING GEOGRAPHY_GRID WITH ( GRIDS =(LEVEL_1 = MEDIUM,LEVEL_2 = MEDIUM,LEVEL_3 = MEDIUM,LEVEL_4 =

optimise mysql query with LIKE operator for 10k records

倾然丶 夕夏残阳落幕 提交于 2019-12-10 12:15:54
问题 Note: So as I figured, the real problem is because of the IN clause I'm using for tagids. Changing the portion of query for text search didn't help much. Any idea how to improve the query? The query takes too long while running on the server. Here Partha S is a search item entered by user. The table contacts contains personal information , tags contains category name and id; and contacts2tags table contains contactid and tagid with values similar to id in contacts and tags respectively.

Retrieving last record in each group from database with additional max() condition in MSSQL

瘦欲@ 提交于 2019-12-10 11:47:01
问题 This is a follow-up question to Retrieving last record in each group from database - SQL Server 2005/2008 In the answers, this example was provided to retrieve last record for a group of parameters (example below retrieves last updates for each value in computername): select t.* from t where t.lastupdate = (select max(t2.lastupdate) from t t2 where t2.computername = t.computername ); In my case, however, "lastupdate" is not unique (some updates come in batches and have same lastupdate value,

How to Bulk Update with SQL Server?

一个人想着一个人 提交于 2019-12-09 19:05:01
问题 I have a table with 10 millions rows that I need to join with another table and update all data. This is taking more than 1 one hour and it is increasing my transaction log in 10+ GBs. Is there another way to enhance this performance? I believe that after each update, the indexes and constraints are checked and all information are logged. Is there a way to tell SQL Server to check constraints only after the update is finished and to minimally log the update action? My query follows below. I

How to measure performance of query in oracle

久未见 提交于 2019-12-09 05:45:33
问题 I'm new to Oracle db. I have 2 queries which return the same result set. I want to measure the performance of each of them and choose the better one. How do I do that using Oracle SQL developer? I remember reading that certain tools provide stats. Any pointers on how to read these stats? Update: As suggested by Rob Van, I used the tkprof utility to find the performance of my queries. A few parameters I could understand (count,rows,elapsed time,execution time), but most I couldn't. Can anybody

SQL: Find missing hierarchy Folders (Paths) in a table

纵饮孤独 提交于 2019-12-06 07:56:50
问题 I have a table which contains Folders Paths. I need to find all the "gaps" between those folders in the hierarchy. I mean that, if the table contains these 3 folders: 'A' 'A\B\C' 'A\B\C\D\E\F\G' I need to find the following missing folders in the hierarchy: 'A\B' 'A\B\C\D' 'A\B\C\D\E' 'A\B\C\D\E\F' This table contains more than 250,000 records of folders, so we seek for the most efficient way to do so, otherwise the script will be stuck for long time, time we don't have. Comment: I don't have

How to store query execution plan so that they can be used later

∥☆過路亽.° 提交于 2019-12-06 04:22:15
问题 My applications runs queries against a sql server database. In many cases I can see the benefit of an execution plan: for example I click for the first time on a button to SELECT * from Tasks WHERE IdUser = 24 AND DATE < '12/12/2010' and DATE > '01/01/2010' it takes 15 seconds the first time, 8 seconds the following times. EDIT: I USE PARAMETRIZED QUERIES. So I have a 7 seconds improvement the second time. Now as I run the application again (so I do a new database connection) the first time

SUBQUERY total performance vs case sum performance

情到浓时终转凉″ 提交于 2019-12-06 00:48:43
I have to do sum of some columns basis on where clause for better understanding i am implementing a temporary table here declare @tbl table(a int ,b int,c int) insert into @tbl values(1,2,3) insert into @tbl values(2,2,3) insert into @tbl values(1,3,1) insert into @tbl values(1,2,3) insert into @tbl values(1,2,3) and for finding sum of a,b,c ob basis of value of a,b,c ; i am using following query SELECT ( SELECT SUM(a) from @tbl where a=1 )AS a , (SELECT SUM(b) from @tbl where b=2 )AS b , (SELECT SUM(c) from @tbl where c=3 )AS c I ask one of my friend to make a single line query for this work