Optimization of query finding related products for a certain product

From: Jacob Nordgren <jacob_nordgren_at_hotmail.com>
Date: 7 Sep 2001 03:32:34 -0700
Message-ID: <47c6b9be.0109070232.2196e3ea_at_posting.google.com>



Hi everybody,

This query finds the related products for a certain product based on user visits.

Today this query takes 3 seconds. Is it possible to make it faster with the same result?

SELECT PRODUCT_ID FROM VISIT WHERE
USER_ID IN (SELECT DISTINCT USER_ID FROM VISIT WHERE PRODUCT_ID = 1883577330)
AND PRODUCT_ID <> 1883577330 GROUP BY PRODUCT_ID ORDER BY COUNT(DISTINCT USER_ID) DESC This is the table:

VISIT



USER_ID INT *
PRODUCT_ID INT *
VISITDATE DATE * Thank you for your help!

/ Jacob Received on Fri Sep 07 2001 - 12:32:34 CEST

Original text of this message