2 ms·
A lot of complex computed properties can easily be made efficient by having "WITH" statements. The with query starts with the ID of the object to which the com
by imtringued 4y ago
A lot of complex computed properties can easily be made efficient by having "WITH" statements.
The with query starts with the ID of the object to which the computed property is attached to. So in this case you would do the same thing as the author and write
WITH comment_vote_count as select comment_id, COUNT(vote_id) from comment left join vote ...
The ORM would just treat this like a normal table and do a join based on the comment ID except the ORM provides a convenient API to do this, which it currently does not...