knowledge-database (beta)

Current group: pgsql.performance

Re: [SQL] OFFSET impact on Performance???

Re: [SQL] OFFSET impact on Performance???  
Merlin Moncure
From:Merlin Moncure
Subject:Re: [SQL] OFFSET impact on Performance???
Date:Thu, 20 Jan 2005 14:29:34 -0500
> this will only work unchanged if the index is unique. imagine , for
> example if you have more than 50 rows with the same value of col.
>
> one way to fix this is to use ORDER BY col,oid

nope! oid is
1. deprecated
2. not guaranteed to be unique even inside a (large) table.

Use a sequence instead.

create view a_b as
select nextval('some_sequnce')::k, a.*, b.* from a, b [...]


select * from a_b where k > k1 order by k limit 1000
*or*
execute fetch_a_b(k1, 1000) <-- pass limit into prepared statement for extra flexibility.


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings
   

Copyright © 2006 knowledge-database   -   All rights reserved