Re: [PERFORM] Query with no result set, really really slow adding ORBDER BY / LIMIT clause

2017-04-21 Thread Pavel Stehule
2017-04-21 9:05 GMT+02:00 Marco Renzi : > > >> I am thinking so limit 1 should be ok. Too big number can be messy >> for optimizer similarly like too small number. >> >> The planner is driven by statistics - and the statistics are not perfect >> - usually it is working on 80% - like weather fo

Re: [PERFORM] Query with no result set, really really slow adding ORBDER BY / LIMIT clause

2017-04-21 Thread Marco Renzi
> > I am thinking so limit 1 should be ok. Too big number can be messy for > optimizer similarly like too small number. > > The planner is driven by statistics - and the statistics are not perfect - > usually it is working on 80% - like weather forecasting. > > Usually it is working, but someti

Re: [PERFORM] Query with no result set, really really slow adding ORBDER BY / LIMIT clause

2017-04-20 Thread Pavel Stehule
2017-04-21 8:49 GMT+02:00 Marco Renzi : > This could look strange, but is fast as hell! > The main problem is: > Is everytime ok doing query like this with order by and limit? Is ok using > an upperlimit to 1.000.000.000 records? > I am thinking so limit 1 should be ok. Too big number can be

Re: [PERFORM] Query with no result set, really really slow adding ORBDER BY / LIMIT clause

2017-04-20 Thread Marco Renzi
This could look strange, but is fast as hell! The main problem is: Is everytime ok doing query like this with order by and limit? Is ok using an upperlimit to 1.000.000.000 records? SELECT * FROM ( SELECT fase.id FROMtipofase JOIN fase ON (fase.tipofase = tipofase.id) WH

Re: [PERFORM] Query with no result set, really really slow adding ORBDER BY / LIMIT clause

2017-04-20 Thread Pavel Stehule
2017-04-20 17:57 GMT+02:00 Pavel Stehule : > > > 2017-04-20 9:19 GMT+02:00 Marco Renzi : > >> Hi!, i've currently a big problem using ORBDER BY / LIMIT in a query >> with no result set. >> If i add the order by/limit clause it runs really really slow. >> >> >> >> QUERY 1 FAST: >>

Re: [PERFORM] Query with no result set, really really slow adding ORBDER BY / LIMIT clause

2017-04-20 Thread Pavel Stehule
2017-04-20 9:19 GMT+02:00 Marco Renzi : > Hi!, i've currently a big problem using ORBDER BY / LIMIT in a query with > no result set. > If i add the order by/limit clause it runs really really slow. > > > > QUERY 1 FAST: > > > SELECT fase.id > FROMtipo

Re: [PERFORM] Query with no result set, really really slow adding ORBDER BY / LIMIT clause

2017-04-20 Thread Marco Renzi
Sorry Vinny, this was what Philip suggested: Have you tried changing your query to: SELECT id FROM fase WHERE tipofase IN (SELECT ID from tipofase WHERE agendafrontoffice = true) ORDER BY id DESC LIMIT 10 OFFSET 0 And this is my log: --

Re: [PERFORM] Query with no result set, really really slow adding ORBDER BY / LIMIT clause

2017-04-20 Thread vinny
On 2017-04-20 13:16, Marco Renzi wrote: Thanks Philip, yes i tried, but that is not solving, still slow. Take a look at the log. -- Limit (cost=3.46..106.87 rows=10 width=4) (

Re: [PERFORM] Query with no result set, really really slow adding ORBDER BY / LIMIT clause

2017-04-20 Thread Marco Renzi
Thanks Philip, yes i tried, but that is not solving, still slow. Take a look at the log. -- Limit (cost=3.46..106.87 rows=10 width=4) (actual time=396555.327..396555.327 rows=0

[PERFORM] Query with no result set, really really slow adding ORBDER BY / LIMIT clause

2017-04-20 Thread Marco Renzi
Hi!, i've currently a big problem using ORBDER BY / LIMIT in a query with no result set. If i add the order by/limit clause it runs really really slow. QUERY 1 FAST: SELECT fase.id FROMtipofase JOIN fase ON (fase.tipofase = tipofase.i