Re: Problems pushing down WHERE-clause to underlying view

2019-02-16 Thread Nicklas Avén
On 16 February 2019 06:02:50 GMT+01:00, Tom Lane wrote: >=?UTF-8?Q?Nicklas_Av=c3=a9n?= writes: >> I also, in the first query, changed the where clause to filter on >> machine_key in table contractor _access. Just to illustrate the >problem >> better. > >> Both queries filter on the same table

Re: Problems pushing down WHERE-clause to underlying view

2019-02-15 Thread Tom Lane
=?UTF-8?Q?Nicklas_Av=c3=a9n?= writes: > I also, in the first query, changed the where clause to filter on > machine_key in table contractor _access. Just to illustrate the problem > better. > Both queries filter on the same table which is joined the same way. But > in the second example the wh

Re: Problems pushing down WHERE-clause to underlying view

2019-02-15 Thread Adrian Klaver
On 2/15/19 12:43 PM, Nicklas Avén wrote: > I have not had chance to fully go through all of below. Some questions/suggestions: > > 1) Thanks for the formatted queries. If I could make a suggestion, when aliasing could you include AS. It would make finding what l.* refers to easier for tho

Re: Problems pushing down WHERE-clause to underlying view

2019-02-15 Thread Nicklas Avén
> I have not had chance to fully go through all of below. Some questions/suggestions: > > 1) Thanks for the formatted queries. If I could make a suggestion, when aliasing could you include AS. It would make finding what l.* refers to easier for those of us with old eyes:) > Yes, of course,

Re: Problems pushing down WHERE-clause to underlying view

2019-02-15 Thread Adrian Klaver
On 2/15/19 9:27 AM, Nicklas Avén wrote: On 2/15/19 5:06 PM, Adrian Klaver wrote: > On 2/15/19 7:28 AM, Nicklas Avén wrote: >> Hi >> >> The problem is that it always calculates all those 22000 rows even if the user id I use only gives 250 rows. >> >> So, the query uses 4 seconds instead o

Re: Problems pushing down WHERE-clause to underlying view

2019-02-15 Thread Nicklas Avén
On 2/15/19 5:06 PM, Adrian Klaver wrote: > On 2/15/19 7:28 AM, Nicklas Avén wrote: >> Hi >> >> The problem is that it always calculates all those 22000 rows even if the user id I use only gives 250 rows. >> >> So, the query uses 4 seconds instead of under 100 ms. > > https://www.postgresql.org

Re: Problems pushing down WHERE-clause to underlying view

2019-02-15 Thread Adrian Klaver
On 2/15/19 7:28 AM, Nicklas Avén wrote: Hi We have a system with 2 layers of views. It is about forestry. The first layer contains the logic like grouping volumes in logs together to stems or harvesting areas and joining species names to codes and things like that. The second layer just jo

Problems pushing down WHERE-clause to underlying view

2019-02-15 Thread Nicklas Avén
Hi We have a system with 2 layers of views. It is about forestry. The first layer contains the logic like grouping volumes in logs together to stems or harvesting areas and joining species names to codes and things like that. The second layer just joins this underlying views to a table with