#152 DBPager creating redundant joins

Core Class
open
Database (15)
5
2011-01-04
2011-01-04
Eloi George
No

phpwsBB calls DBPager->addjoin 3 times to add 3 sortable columns to the forum listing. Instead of creating 1 join in th resulting sql, DBPager creates 3.

SELECT DISTINCT
phpwsbb_topics.*,
dbp1.title AS title,
dbp2.creator AS creator,
dbp3.times_viewed AS times_viewed
FROM
phpws_key,
phpwsbb_topics
LEFT JOIN phpws_key as dbp1
ON phpwsbb_topics.key_id = dbp1.id
LEFT JOIN phpws_key as dbp2
ON phpwsbb_topics.key_id = dbp2.id
LEFT JOIN phpws_key as dbp3
ON phpwsbb_topics.key_id = dbp3.id
WHERE
(phpwsbb_topics.fid = '6' AND phpws_key.active = '1')
AND (phpwsbb_topics.total_posts > '0' OR phpwsbb_topics.is_phpwsbb = '0')
ORDER BY
phpwsbb_topics.sticky desc,phpwsbb_topics.lastpost_date desc
LIMIT 0 , 30
;================
The following patch allows DBPager to let extra columns submitted for the same table use the same alias.

Discussion

  • Eloi George
    Eloi George
    2011-01-04

    DBPager patch

     
    Attachments