query-performance

Utilizing parallel query execution in Postgresql for SELECT INTO

偶尔善良 提交于 2019-12-11 17:56:17
问题 Is parallel query execution in Postgresql supported for SELECT INTO queries? 回答1: No. Parallel execution is not available for DDL statements - only for read only queries. The deprecated SELECT .. INTO ... creates a new table and thus it qualifies as DDL. It is also recommended to use CREATE TABLE .. AS SELECT ... instead. Update: Postgres 11 (to be released end of 2018) will support parallel query execution for CREATE TABLE ... AS SELECT ... 来源: https://stackoverflow.com/questions/47057891

Postgres `gin_trgm_ops` index not being used

℡╲_俬逩灬. 提交于 2019-12-11 15:56:53
问题 I'm trying to speed up some text matching in Postgres, using the pg_trgm extensions: CREATE TABLE test3 (id bigint, key text, value text); insert into test3 values (1, 'first 1', 'second 3'); insert into test3 values (2, 'first 1', 'second 2'); insert into test3 values (2, 'first 2', 'second 3'); insert into test3 values (3, 'first 1', 'second 2'); insert into test3 values (3, 'first 1', 'second 3'); insert into test3 values (4, 'first 2', 'second 3'); insert into test3 values (4, 'first 2',

DB2 performance issue while executing select query

牧云@^-^@ 提交于 2019-12-11 15:33:38
问题 I have this query: SELECT INVOICE_NUMBER, INVOICE_SEQ_NUMBER, FILE_NUMBER, MAX(INVOICE_SEQ_NUMBER) OVER (PARTITION BY INVOICE_NUMBER) AS MAX_INV_SEQ_NUM FROM (SELECT A.INVOICE_NUMBER, A.INVOICE_SEQ_NUMBER, B.FILE_NUMBER, DENSE_RANK() OVER (ORDER BY A.INVOICE_NUMBER) as seqnum FROM TABLE1 A JOIN TABLE2 B ON A.INVOICE_NUMBER = B.INVOICE_NUMBER AND A.INVOICE_SEQ_NUMBER = B.INVOICE_SEQ_NUMBER ) t WHERE seqnum <= 500; It was working fine with 10000 records in the tables but we added more today(

MongoDB: degraded query performance

浪子不回头ぞ 提交于 2019-12-11 12:35:43
问题 I have a user's collection in MongoDB with over 2.5 million of records which constitute to 30 GB. I have about 4 to 6 GB of indexes. It's in sharded environment with two shards, each consisting of replica set. Servers are dedicated especially to Mongo with no overhead. Total RAM is over 10 GB which more than enough for the kind of queries I am performing (shown below). My concern is that despite of having indexes to the appropriate fields time to retrieve the result is huge (2 minutes to

Fast dynamic named set calculation

时光总嘲笑我的痴心妄想 提交于 2019-12-11 06:23:24
问题 I have a long complex query with a lot of calculations and conditions but the main structure looks like this: WITH MEMBER [Id1] AS [Level].[Level1].CurrentMember.Member_Key MEMBER [Id2] AS [Level].[Level2].CurrentMember.Member_Key MEMBER [Level].[Level1].[FirstSet] AS NULL MEMBER [Level].[Level1].[SecondSet] AS NULL SET [Set 1] AS {some processed set members} SET [Set 2] AS {some other processed set members} SET [Common CrossJoin Set] AS [Level].[Level2].Members MEMBER [Calculated Measure 1]

Why is this CTE so much slower than using temp tables?

和自甴很熟 提交于 2019-12-11 04:04:19
问题 We had an issue since a recent update on our database (I made this update, I am guilty here), one of the query used was much slower since then. I tried to modify the query to get faster result, and managed to achieve my goal with temp tables , which is not bad, but I fail to understand why this solution performs better than a CTE based one , which does the same queries. Maybe it has to do that some tables are in a different DB ? Here's the query that performs badly (22 minutes on our hardware

SQL query performance statistics messages returned multiple times

為{幸葍}努か 提交于 2019-12-11 00:52:54
问题 I am running this query 1 on SQL Server management studio and see it returns me like 3 messages, but same when inside stored procedure has nearly 10 - 20 messages from Statistics. Whats happening and why do i see them ? SET STATISTICS IO,TIME ON; GO SELECT [UserId] ,[UserType] ,[CreateDT] ,[EffectiveDT] FROM [dbo].[People] ORDER BY [UserId] SET STATISTICS IO,TIME OFF; GO Messages i receive are below SQL Server parse and compile time: CPU time = 0 ms, elapsed time = 0 ms. SQL Server parse and

MySQL query performance

早过忘川 提交于 2019-12-10 23:31:47
问题 I have the following table structure: EVENT_ID(INT) EVENT_NAME(VARCHAR) EVENT_DATE(DATETIME) EVENT_OWNER(INT) I need to add the field EVENT_COMMENTS which should be a text field or a very big VARCHAR . I have 2 places where I query this table, one is on a page that lists all the events (in that page I do not need to display the event_comments field). And another page that loads all the details for a specific events, which I will need to display the event_comments field on. Should I create an

Is there Performance related difference in using aggregate function in ORDER BY clause and alias of aggregate function?

隐身守侯 提交于 2019-12-10 23:02:02
问题 I have a question related to ORDER BY or GROUP BY clause. For example I have below queries SELECT country_name,COUNT(*) FROM user_location WHERE country_name IS NOT NULL GROUP BY country_name ORDER BY COUNT(*) DESC And SELECT country_name,COUNT(*) As Total FROM user_location WHERE country_name IS NOT NULL GROUP BY country_name ORDER BY Total DESC In 2nd query I am using alias Total for COUNT(*) in ORDER BY clause. Is there any performance related differences in two queries ? 回答1: I've run the

Improving query performance by using views

╄→尐↘猪︶ㄣ 提交于 2019-12-10 18:49:47
问题 I have a large table with 10+ millions records in a SQL Server database. The table contains certain type of data for all 50 states in the US. So if I create 50 views, one for each state, from this table, would the performance of making queries from my application be improved? Other suggestions? 回答1: No. A view is a macro that expands so the same tables end up in the plan anyway. Unless it's indexed. 50 indexed views is most likely overkill. If you have slow performance with 50 million rows