Re: Postgres trigger side-effect is occurring out of order with row-level security select policy

2018-09-30 Thread Charles Clavadetscher (SwissPUG)
An addition On 01.10.2018 05:18:15, Charles Clavadetscher (SwissPUG) wrote: Hello On 01.10.2018 05:00:02, Carl Sverre wrote: Thank you for the detailed report Charles. I think you may be missing the “returning id” clause in the insert. Can you verify it works when you use “returning id”? Th

Re: Postgres trigger side-effect is occurring out of order with row-level security select policy

2018-09-30 Thread Charles Clavadetscher (SwissPUG)
Hello On 01.10.2018 05:00:02, Carl Sverre wrote: Thank you for the detailed report Charles. I think you may be missing the “returning id” clause in the insert. Can you verify it works when you use “returning id”? Thanks! [Charles] : You are right: testuser@charles.localhost=> INSERT INTO a VAL

Re: Postgres trigger side-effect is occurring out of order with row-level security select policy

2018-09-30 Thread Charles Clavadetscher (SwissPUG)
Hello On 30.09.2018 23:31:32, Adrian Klaver wrote: On 9/30/18 1:13 PM, Carl Sverre wrote: > Thanks for the initial results. Can you check that you are not using > super permissions and are enabling row security when running the test? > Super ignores row security. Yeah, big oops on my part, I was

Re: Why my query not using index to sort?

2018-09-30 Thread Adrian Klaver
On 9/30/18 1:21 PM, Arup Rakshit wrote: Hi Adrian, I am on psql (10.5, server 9.5.14). I am still investigating the Rails side. I found a blog (https://schneems.com/2015/10/27/sql-in-rails-logs.html) , where a Rails core team member said that Load time is basically SQL execution time. From

Re: Postgres trigger side-effect is occurring out of order with row-level security select policy

2018-09-30 Thread Adrian Klaver
On 9/30/18 1:13 PM, Carl Sverre wrote: Thanks for the initial results. Can you check that you are not using super permissions and are enabling row security when running the test? Super ignores row security. Yeah, big oops on my part, I was running as superuser. Running as non-superuser result

Re: Why my query not using index to sort?

2018-09-30 Thread Arup Rakshit
Hi Adrian, I am on psql (10.5, server 9.5.14). I am still investigating the Rails side. I found a blog (https://schneems.com/2015/10/27/sql-in-rails-logs.html ) , where a Rails core team member said that Load time is basically SQL executi

Re: How to improve sql query to achieve the better plan

2018-09-30 Thread Pavel Stehule
ne 30. 9. 2018 v 18:49 odesílatel Arup Rakshit napsal: > I just added it as you said, but I am getting same plan. > > > Sort (cost=62842.16..62846.91 rows=1897 width=35) (actual > time=1845.831..1845.950 rows=1229 loops=1) > Sort Key: projects.id > Sort Method: quicksort Memory: 145kB > -

Re: How to improve sql query to achieve the better plan

2018-09-30 Thread Arup Rakshit
I just added it as you said, but I am getting same plan. Sort (cost=62842.16..62846.91 rows=1897 width=35) (actual time=1845.831..1845.950 rows=1229 loops=1) Sort Key: projects.id Sort Method: quicksort Memory: 145kB -> HashAggregate (cost=62710.42..62738.88 rows=1897 width=35) (actual

Re: How to improve sql query to achieve the better plan

2018-09-30 Thread Pavel Stehule
Hi ne 30. 9. 2018 v 18:23 odesílatel Arup Rakshit napsal: > I have the below query which is taking 1873 ms. How can I improve this? > > explain analyze select > sum(coalesce(price_cents, 0)::bigint * coalesce(quantity, 0) * (1 - > coalesce(workitems.discount, 0)/ 100)) as total_budget_cents, > s

How to improve sql query to achieve the better plan

2018-09-30 Thread Arup Rakshit
I have the below query which is taking 1873 ms. How can I improve this? explain analyze select sum(coalesce(price_cents, 0)::bigint * coalesce(quantity, 0) * (1 - coalesce(workitems.discount, 0)/ 100)) as total_budget_cents, sum(coalesce(price_cents, 0)::bigint * coalesce(quantity

Re: vacuum question

2018-09-30 Thread Stephen Frost
Greetings, * Torsten Förtsch (tfoertsch...@gmail.com) wrote: > I have a table with a really small number of rows, usually about 1500, > sometimes may be up to 5000. The usage pattern of that table is such that > rows are inserted and kept for a while, mostly seconds or minutes but > theoretically

vacuum question

2018-09-30 Thread Torsten Förtsch
Hi, I have a table with a really small number of rows, usually about 1500, sometimes may be up to 5000. The usage pattern of that table is such that rows are inserted and kept for a while, mostly seconds or minutes but theoretically up to 1 year. After that they are deleted. No updates, just inser

Re: How to maintain the csv log files in pg_log directory only for past 30 days

2018-09-30 Thread Peter J. Holzer
On 2018-09-29 07:12:32 -0700, Adrian Klaver wrote: > On 9/28/18 7:05 PM, Raghavendra Rao J S V wrote: > > Hope you all are recommending below settings to maintain only max 30 > > days logs in *pg_log* directory. Please correct me if I am wrong. > > Well it would actually be 31 days as: > > http:/

Re: Postgres trigger side-effect is occurring out of order with row-level security select policy

2018-09-30 Thread Charles Clavadetscher (SwissPUG)
Hello On 29.09.2018 20:24:45, Adrian Klaver wrote: On 9/28/18 11:35 PM, Carl Sverre wrote: > *Context* > I am using row-level security along with triggers to implement a pure > SQL RBAC implementation. While doing so I encountered a weird behavior > between INSERT triggers and SELECT row-level s