[GENERAL] 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

Re: [GENERAL] Problem with REFERENCES on INHERITS

2015-02-01 Thread David G Johnston
William Gordon Rutherdale wrote > I have encountered a problem with references when using INHERITS (on > Postgres 9.1/9.2). Could someone please explain why this occurs. > > My problem: could someone please explain the semantics and why this > behaviour makes sense -- or is it a design error or

[GENERAL] Problem with REFERENCES on INHERITS

2015-02-01 Thread William Gordon Rutherdale
Hi. I have encountered a problem with references when using INHERITS (on Postgres 9.1/9.2). Could someone please explain why this occurs. Consider this example. CREATE TABLE primate ( id SERIAL PRIMARY KEY, name TEXT, tale TEXT ); CREATE TABLE chimp ( human_friend TEXT ) INHERITS