Je doute que ça optimise grand chose, mais c'est pas bizarre ce bout là :
AND ((post_dt = '2004-10-12 10:33:29' AND P.post_id > 2795) OR post_dt >
'2004-10-12 10:33:29' )
Si j'ai bien compris, on s'en fout que le post_id soit > ou non à 2795, on
cherche juste un post publié après le 12/10/2004 ?
Sinon, oui, tu peux nous donner le résultat du explain ?
Le 20 décembre 2012 10:41, Julien Wajsberg <felash(a)gmail.com> a écrit :
sur mysql ou postgre ?
ajoute "explain" devant et mysql t'expliquera ce qu'il fait.
il manque peut-être des indexes ? (je connais pas le schéma donc j'essaie
de deviner juste)
On 20 December 2012 10:33, Franck Paul <carnet.franck.paul(a)gmail.com>wrote:
> 'Jour les gens,
>
> Les vacances arrivent, vous aller vous ennuyer, forcément, alors j'ai
> pensé à vous !
>
> Voilà :
>
> Lorsqu'on cherche le billet suivant d'un billet affiché, par exemple, on
> (enfin Dotclear) exécute ce
> genre de requête :
>
> SELECT P.post_id, P.blog_id, P.user_id, P.cat_id, post_dt, post_tz,
> post_creadt, post_upddt, post_format, post_password, post_url, post_lang,
> post_title, post_excerpt, post_excerpt_xhtml, post_content,
> post_content_xhtml, post_notes, post_type, post_meta, post_status,
> post_selected, post_position, post_open_comment, post_open_tb, nb_comment,
> nb_trackback, U.user_name, U.user_firstname, U.user_displayname,
> U.user_email, U.user_url, C.cat_title, C.cat_url, C.cat_desc FROM dc_post P
> INNER JOIN dc_user U ON U.user_id = P.user_id LEFT OUTER JOIN dc_category C
> ON P.cat_id = C.cat_id WHERE P.blog_id = 'open-time' AND ((post_status = 1
> AND post_password IS NULL ) ) AND post_type IN ('post') AND ( (post_dt
> = '2004-10-12 10:33:29' AND P.post_id > 2795) OR post_dt >
'2004-10-12
> 10:33:29' ) ORDER BY post_dt ASC, P.post_id ASC LIMIT 1;
>
> Sur mon blog ça donne ça :
>
> # Query_time: 2.021316 Lock_time: 0.000466 Rows_sent: 1 Rows_examined:
> 12730
>
> Pour résumer le nombre de lignes parcourues est assez volumineux.
>
> Comment peut-on optimiser ce genre de requête ?
>
> Vous avez jusque début janvier et d'ici là passez de bonnes fêtes !
>
> Franck
>
>
> _______________________________________________
> Dev mailing list
> Dev(a)list.dotclear.org
>
http://ml.dotclear.org/listinfo/dev
>
>
_______________________________________________
Dev mailing list
Dev(a)list.dotclear.org
http://ml.dotclear.org/listinfo/dev