Suggestion to optimize performance of the PLSQL procedure.

2018-07-11 Thread Dinesh Chandra 12108
Dear expert, Could you please review and suggest to optimize performance of the PLSQL procedure in PostgreSQL? I have attached the same. Thanks in advance Regards, Dinesh Chandra DISCLAIMER: This email message is for the sole use of the intended recipient(s)

Re: Improving Performance of Query ~ Filter by A, Sort by B

2018-07-11 Thread Tom Lane
Lincoln Swaine-Moore writes: > Here's the result (I turned off the timeout and got it to finish): > ... I think the core of the problem here is bad rowcount estimation. We can't tell from your output how many rows really match > WHERE "a"."parent_id" IN ( > 49188,14816,14758,8402 > ) but t

Re: Improving Performance of Query ~ Filter by A, Sort by B

2018-07-11 Thread Lincoln Swaine-Moore
Thanks for looking into this! Here's the result (I turned off the timeout and got it to finish): EXPLAIN ANALYZE SELECT "a"."id" FROM a_partition1 "a" WHERE "a"."parent_id" IN ( 49188,14816,14758,8402 ) ORDER BY "a"."tmstmp" DESC LIMIT 20; QUERY PLAN

Re: Improving Performance of Query ~ Filter by A, Sort by B

2018-07-11 Thread legrand legrand
Hello, I have tested it with release 11 and limit 20 is pushed to each partition when using index on tmstmp. Could you tell us what is the result of your query applyed to one partition EXPLAIN ANALYZE SELECT "a"."id" FROM a_partition1 "a" WHERE "a"."parent_id" IN ( 34226,24506,40987,27162