Re: [GENERAL] Slow query: select * order by XXX desc offset 10 limit 10

2011-10-14 Thread Alban Hertroys
On 14 Oct 2011, at 13:58, Alexander Farber wrote: > Hi Alban and others - > > On Fri, Oct 14, 2011 at 1:34 PM, Alban Hertroys wrote: >> Anyway, I think you get the sequential scans because the UNION requires to >> sort all the data from both tables to guarantee that the results are unique >> (

Re: [GENERAL] Slow query: select * order by XXX desc offset 10 limit 10

2011-10-14 Thread Alexander Farber
Hi Alban and others - On Fri, Oct 14, 2011 at 1:34 PM, Alban Hertroys wrote: > Anyway, I think you get the sequential scans because the UNION requires to > sort all the data from both tables to guarantee that the results are unique > (hence that long Sort Key at the 7th line of explain output).

Re: [GENERAL] Slow query: select * order by XXX desc offset 10 limit 10

2011-10-14 Thread Alban Hertroys
On 14 Oct 2011, at 11:14, Alexander Farber wrote: > I've added 3 new indices on both tables: > > > quincy=> \d quincynoreset > Table "public.quincynoreset" > Column|Type | Modifiers > -+-+--- > apps

Re: [GENERAL] Slow query: select * order by XXX desc offset 10 limit 10

2011-10-14 Thread Pavel Stehule
2011/10/14 Alexander Farber : > Thank you - > > On Fri, Oct 14, 2011 at 11:30 AM, Pavel Stehule > wrote: >> you should to use a DECLARE statement >> http://www.postgresql.org/docs/9.1/interactive/sql-declare.html >> and fetch statement >> http://www.postgresql.org/docs/9.1/interactive/sql-fetch.h

Re: [GENERAL] Slow query: select * order by XXX desc offset 10 limit 10

2011-10-14 Thread Alexander Farber
Thank you - On Fri, Oct 14, 2011 at 11:30 AM, Pavel Stehule wrote: > you should to use a DECLARE statement > http://www.postgresql.org/docs/9.1/interactive/sql-declare.html > and fetch statement > http://www.postgresql.org/docs/9.1/interactive/sql-fetch.html I've managed to create a cursor and c

Re: [GENERAL] Slow query: select * order by XXX desc offset 10 limit 10

2011-10-14 Thread Pavel Stehule
Hello you should to use a DECLARE statement http://www.postgresql.org/docs/9.1/interactive/sql-declare.html and fetch statement http://www.postgresql.org/docs/9.1/interactive/sql-fetch.html Regards Pavel Stehule 2011/10/14 Alexander Farber : > I've also tried opening cursor: > > quincy=> op

Re: [GENERAL] Slow query: select * order by XXX desc offset 10 limit 10

2011-10-14 Thread Alexander Farber
I've also tried opening cursor: quincy=> open ref for select to_char(qdatetime, '-MM-DD') as QDATETIME,ID,NAME,CATEGORY,APPSVERSION,OSVERSION,DETAILS,DEVINFO from quincyview where qdatetime <= now() order by QDATETIME desc ; ERROR: syntax error at or near "open" LINE 1: open ref for select to

Re: [GENERAL] Slow query: select * order by XXX desc offset 10 limit 10

2011-10-14 Thread Alexander Farber
Hello Bill and others, On Thu, Oct 13, 2011 at 4:09 PM, Bill Moran wrote: > In response to Alexander Farber : >> I use PostgreSQL 8.4.7 on CentOS 6.0 / 64 bit machine >> with Quad-Core AMD Opteron(tm) Processor 2352 and >> 16 GB RAM and use it for 1 PHP script - which selects >> and displays data

Re: [GENERAL] Slow query: select * order by XXX desc offset 10 limit 10

2011-10-13 Thread Bill Moran
In response to Alexander Farber : > Hello, > > I use PostgreSQL 8.4.7 on CentOS 6.0 / 64 bit machine > with Quad-Core AMD Opteron(tm) Processor 2352 and > 16 GB RAM and use it for 1 PHP script - which selects > and displays data in jQuery DataTables (i.e. an > HTML-table which can be viewed page

Re: [GENERAL] Slow query: select * order by XXX desc offset 10 limit 10

2011-10-13 Thread David Johnston
On Oct 13, 2011, at 9:41, Alexander Farber wrote: > > Does anybody please have an idea, > how to speed up my select statements? > Create one or more indexes. David J.

[GENERAL] Slow query: select * order by XXX desc offset 10 limit 10

2011-10-13 Thread Alexander Farber
Hello, I use PostgreSQL 8.4.7 on CentOS 6.0 / 64 bit machine with Quad-Core AMD Opteron(tm) Processor 2352 and 16 GB RAM and use it for 1 PHP script - which selects and displays data in jQuery DataTables (i.e. an HTML-table which can be viewed page by page). I select records from 1 view which uni