PostgreSQL as a secret weapon for high-performance ... - PGCon
PostgreSQL as a secret weapon for high-performance ... - PGCon
PostgreSQL as a secret weapon for high-performance ... - PGCon
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Rails <strong>as</strong> ORM > Multiplying Queries<br />
create table T<strong>as</strong>k (<br />
id serial not null,<br />
parent_id integer<br />
)<br />
cl<strong>as</strong>s T<strong>as</strong>k < ActiveRecord::B<strong>as</strong>e<br />
acts_<strong>as</strong>_tree<br />
end<br />
Should rather be:<br />
select * from t<strong>as</strong>ks<br />
left outer join<br />
(select id <strong>as</strong> parents_id, parent_id <strong>as</strong> parents_parent_id from t<strong>as</strong>ks)<br />
<strong>as</strong> parents on (t<strong>as</strong>ks.parent_id = parents_id)<br />
left outer join<br />
(select id <strong>as</strong> parents_parents_id from t<strong>as</strong>ks)<br />
<strong>as</strong> parents_parents on (parents_parent_id = parents_parents_id)<br />
Gleb Arshinov & Alex Dymo ● <strong>PostgreSQL</strong> <strong>as</strong> a <strong>secret</strong> <strong>weapon</strong> <strong>for</strong> <strong>high</strong>-per<strong>for</strong>mance Ruby on Rails applications ● <strong>PGCon</strong> 2010 10 / 58