Re: [HACKERS] How do I bump a row to the front of sort efficiently

2015-02-01 Thread David G Johnston
sam.saffron wrote > I have this query: > > select * from topics > order by case when id=1 then 0 else 1 end, bumped_at desc > limit 30 > > It works fine, bumps id 1 to the front of the sort fine but is > terribly inefficient and scans > > OTH > > "select * from topics where id = 1" is super fas

[HACKERS] How do I bump a row to the front of sort efficiently

2015-02-01 Thread Sam Saffron
I have this query: select * from topics order by case when id=1 then 0 else 1 end, bumped_at desc limit 30 It works fine, bumps id 1 to the front of the sort fine but is terribly inefficient and scans OTH "select * from topics where id = 1" is super fast "select * from topics order by bumped_a