I have built a view with many fields from the same table. The resulting query was very slow, and slowed down the access to the database server for a while.

I found out that the query did a join on the field nid in this table, but the field was not indexed: maybe the join was to be made on the vid field, (this may be a bug in the module that defines this table).

Adding an index on that field, the query has become quicker, but the result contained many duplicated istances of each node.

Activating the option "distinct" in the view removed the duplicates, but I found out also that the query generated for the view does multiple joins on the table containing the fields used, but in computations it uses only the first alias.

So I found in views that add_table adds multiple times the same table, but it's also available ensure_table that adds it just one time.

I tried to replace the four calls to add_table() in computed_field with ensure_table(). Now the query has no more duplicated joins, and has become quicker and more efficient, and now doesn't generate duplicates when distinct option is disabled.

Comments

fabio84’s picture

Project: Computed Field » Views Calc
Version: 6.x-1.0-beta3 » 6.x-1.3

Oops... Sorry... Wrong module. I mean Views Calc.

I was in a hurry and I had no time to check again.

karens’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

The D6 version is no longer supported.