I turned on Devel mysql log; those two queries took too much time:

47773.51 ms 

execute 

SELECT COUNT(*) FROM (SELECT DISTINCT(node.nid) AS nid FROM node node LEFT JOIN content_type_product node_data_field_brand ON node.vid = node_data_field_brand.vid LEFT JOIN node node_node_data_field_brand ON node_data_field_brand.field_brand_nid = node_node_data_field_brand.nid LEFT JOIN image_attach image_attach ON node.nid = image_attach.nid LEFT JOIN image_attach node_node_data_field_brand__image_attach ON node_node_data_field_brand.nid = node_node_data_field_brand__image_attach.nid WHERE node.type in ('product') ) count_alias
47879.11 ms

execute

SELECT DISTINCT(node.nid) AS nid, node.title AS node_title, image_attach.iid AS image_attach_iid, node_node_data_field_brand__image_attach.iid AS node_node_data_field_brand__image_attach_iid FROM node node LEFT JOIN content_type_product node_data_field_brand ON node.vid = node_data_field_brand.vid LEFT JOIN node node_node_data_field_brand ON node_data_field_brand.field_brand_nid = node_node_data_field_brand.nid LEFT JOIN image_attach image_attach ON node.nid = image_attach.nid LEFT JOIN image_attach node_node_data_field_brand__image_attach ON node_node_data_field_brand.nid = node_node_data_field_brand__image_attach.nid WHERE node.type in ('product') ORDER BY node_title ASC LIMIT 0, 50

Also, attached image based on node reference doesn't work.

CommentFileSizeAuthor
#7 image-HEAD.image-attach-indexes.patch1.85 KBsun

Comments

skyredwang’s picture

To simplify the problem, I ran this in MySQL " select node.nid from node left join image_attach on node.nid=image_attach.nid where node.type='product';" and it took 25 sec??
I have 25,000 records in {node} and 1,892 records in {image_attach}

skyredwang’s picture

Status: Active » Needs work

The problem really is that {image_attach| doesn't have an index, which causes the slowness. So, I created an index for it. Please alter the table in the next release.

skyredwang’s picture

The image_attach view still doesn't work with the relationship

drewish’s picture

Status: Needs work » Active

roll a freaking patch then.

sun’s picture

Title: Serious perfermance issue for image attache Views support and Views relationship for attach image doesn't work » Performance: Missing index for image_attach.nid

Please submit a proper patch. See http://drupal.org/patch for details.

skyredwang’s picture

Assigned: Unassigned » skyredwang

Sure, I will read through the documentation, and submit a patch next week

sun’s picture

Version: 6.x-1.x-dev » 6.x-1.0-alpha4
Assigned: skyredwang » Unassigned
Status: Active » Fixed
StatusFileSize
new1.85 KB

Committed attached patch.

Status: Fixed » Closed (fixed)

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