Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This patch removes the kind of redundant joins in Views queries that CCK tends to create. See http://groups.drupal.org/node/11288 for discussion.
Comment | File | Size | Author |
---|---|---|---|
#2 | query-optimize-256381-2.patch | 2.65 KB | bjaspan |
query-optimize.patch | 1.78 KB | bjaspan | |
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedQuick code style comments: unary operator ! should not have space between it and the variable it operates on. $quetab should probably be an actual word (I'm less strict about that than Drupal default style, though) but I'd be just as happy with $table for the variable.
We definitely have to run it through adjust_join or it won't match.
If the join is run through adjust_join you *may* not need to check relationship which means we might be able to do something slick with array_filter? It may be faster.
Comment #2
bjaspan CreditAttribution: bjaspan commentedThe patch now handles adjust_join() correctly (I think :-)). I made a simple test case: Content type test1 has three single value fields:
- field_field1: text
- field_field2: integer
- field_noderef: noderef to 'story'
Without the optimization, we get the query:
With the optimization, we get the query:
I also fixed the style comments.
This patch has 11 lines of code (including four "}") and 28 lines of comments. ;-)
I just realized a problem. The optimization is working, but the selected fields are getting the wrong AS name: they are being based on the existed queued table name, not the optimized-away joined table name. This needs to be fixed.
Comment #3
bjaspan CreditAttribution: bjaspan commentedDiscussion with Earl on IRC concludes that the field renaming issue I mentioned above is not a problem; Views does not guarantee that fields names will be consistent and provides other mechanisms for accessing the data reliably. Therefore, CNR.
Comment #4
merlinofchaos CreditAttribution: merlinofchaos commentedCommitted!
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.