sqlperformance

How can I speed up this PostgreSQL UPDATE FROM sql query? It currently takes days to finish running

只谈情不闲聊 提交于 2021-02-10 14:55:18
问题 How can I speed up the PostgreSQL UPDATE FROM sql query below? It currently takes days to finish running. UPDATE import_parts ip SET part_part_id = pp.id FROM parts.part_parts pp WHERE pp.upc = ip.upc AND (ip.status is null or ip.status != '6'); And why does it takes days to run in the first place? Most of the time, I manually kill the query because it takes too long to run like more than 24 hours. Last time it successfully finished running, it took almost 38 hours. import_parts table has

Query performance WHERE clause contains IN (subquery)

℡╲_俬逩灬. 提交于 2021-02-07 03:34:29
问题 SELECT Trade.TradeId, Trade.Type, Trade.Symbol, Trade.TradeDate, SUM(TradeLine.Notional) / 1000 AS Expr1 FROM Trade INNER JOIN TradeLine ON Trade.TradeId = TradeLine.TradeId WHERE (TradeLine.Id IN (SELECT PairOffId FROM TradeLine AS TradeLine_1 WHERE (TradeDate <= '2011-05-11') GROUP BY PairOffId HAVING (SUM(Notional) <> 0))) GROUP BY Trade.TradeId, Trade.Type, Trade.Symbol, Trade.TradeDate ORDER BY Trade.Type, Trade.TradeDate I am concerned about the performance of the IN in the WHERE clause

Query performance WHERE clause contains IN (subquery)

狂风中的少年 提交于 2021-02-07 03:33:15
问题 SELECT Trade.TradeId, Trade.Type, Trade.Symbol, Trade.TradeDate, SUM(TradeLine.Notional) / 1000 AS Expr1 FROM Trade INNER JOIN TradeLine ON Trade.TradeId = TradeLine.TradeId WHERE (TradeLine.Id IN (SELECT PairOffId FROM TradeLine AS TradeLine_1 WHERE (TradeDate <= '2011-05-11') GROUP BY PairOffId HAVING (SUM(Notional) <> 0))) GROUP BY Trade.TradeId, Trade.Type, Trade.Symbol, Trade.TradeDate ORDER BY Trade.Type, Trade.TradeDate I am concerned about the performance of the IN in the WHERE clause

Sybase: Stored Procedure called from within another Stored Procedure is too slow

亡梦爱人 提交于 2020-01-25 08:10:10
问题 I'm writing a stored procedure for a Sybase database. I'm using Sybase Central 16.0 as my development environment. The machine I'm using runs Microsoft Windows Server 2012 R2 Standard and has 16GB RAM running on a 2.8GHz CPU. My stored procedure uses a cursor to iterate over the records in a table with about 400,000 reecords. Each record is written incrementally into a LONG VARCHAR variable and every Nth record the proc will run an MD5 hash value on the variable and store the value in a

MySQL performance of query making addition of columns in where clause

回眸只為那壹抹淺笑 提交于 2020-01-15 11:17:44
问题 I have a query making an addition of several column values in the WHERE clause. I can't precompute this addition in a single column because the combination of columns to use varies between queries. My problem is that my table is very large (several hundreds of millions of rows) and the performances very bad. Example table: +---------+------------+--------+--------+--------+--------+ | tableId | categoryId | value1 | value2 | value3 | value4 | +---------+------------+--------+--------+--------

SQL Query - long running / taking up CPU resource

时光总嘲笑我的痴心妄想 提交于 2020-01-06 03:27:26
问题 Hello I have the below SQL query that is taking on average 40 minutes to run, one of the tables that it references has over 7 million records in it. I have ran this through the database tuning advisor and applied all recommendations, also I have assesed it within the activity monitor in sql and no further indexes etc have been recommended. Any suggestions would be great, thanks in advance WITH CTE AS ( SELECT r.Id AS ResultId, r.JobId, r.CandidateId, r.Email, CAST(0 AS BIT) AS EmailSent, NULL

Regarding Sql Profiling

半世苍凉 提交于 2020-01-05 05:09:16
问题 I want to know how to use the sql profiling tool for sql server 2008. for the anjlab sql profiler what filters should be set in order to get the exact query?? 回答1: Assuming the anjlab profiler works in a similar fashion to the standard profiler, I'd suggest capturing rpc completed and sql batch completed events. Those are the two that will tell you the most about what queries are being called on the system. For detailed analysis, you could add statement completed events, but be prepared for

How To Avoid TempTable in Union All when queries contain DIFFERENT order by and inner join?

百般思念 提交于 2019-12-24 18:42:26
问题 What i am trying to do is always sending Product with 0 quantity to the end of an already sorted temp Table without losing current sorting (as i described in the following question How to send Zero Qty Products to the end of a PagedList<Products>?) I have one Sorted temptable which is filled (it is sorted by what user has selected like Alphabetic , by Price or by Newer product,sorting is based identity id) : CREATE TABLE #DisplayOrderTmp ( [Id] int IDENTITY (1, 1) NOT NULL, [ProductId] int

jpa namedquery with literals changed to prepared statement

大城市里の小女人 提交于 2019-12-24 13:15:15
问题 I have a jpa (openjpa-2.2.1) namedquery that has some hardcoded literals (ex: a.status <> 'X') - the problem is at runtime the generated query is actually a prepared statement (a.status <> ?) Is there a way to force JPA run the query as is? (i would like to keep it as namedquery, not implement it as native query or other ways) I would like to run the query as is because of performance reasons - the static query runs in a db client in about 2 seconds while the prepared statement fired from

SQL Long running query / maxing out server resource e.g. RAM/CPU

ε祈祈猫儿з 提交于 2019-12-24 10:22:23
问题 I originally posted the following thread SQL Query - long running / taking up CPU resource My issue was the SARGABILITY of my query, having addressed that (see the previous thread but in short I was using a lot of ISNULL functions which were bypassing the index scans) I am now having further issues. My SQL server settings are as below: cost threshold for parallelism 5 max degree of parallelism 0 My query still takes 2:13 to run and causes CPU / Memory spikes, I have a largely capable server e