I am using views 2 programmatically to execute queries to get data about field values. Views is a great option because it allows users to configure their own ordering/filters/displays etc.. but still allows my module to add it's own field items and filter items before building and executing the SQL.

One thing I've noticed is that views automatically adds the base field (i.e; nid) into the SELECT statement. There is no way to prevent this. I know that for most obvious operations the nid is essential, however for my purposes it destroys the 'group by' optimisation I've added. If the nid is there I can't 'group by' any other value since it actually groups per each potential result, which really means there is no grouping.

Bottom line is that views is unnecessarily selecting a row for every node, when really all I need are the unique field values regardless of how many nodes they appear in. Ultimately I am building an array keyed by the field value, so the duplicates dissapear anyway, but it adds more processing overhead.

Can we please have some way to flag the view programatically, at least, to instruct it to NOT add the base field? That would give me more control of the built query and reduce the execution and rendering time for my use case.

Comments

merlinofchaos’s picture

Status: Active » Fixed

This already happens in Views 3, where GROUP BY is now supported. It probably won't change in Views 2.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.