Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You need only two fields in your <code>group by</code> (and if the field <code>event_id</code> is the primary key you only need <strong>that</strong> field.<br> Having group by to consider less fields should make your query faster.<br> You should only put <strong>functionally independent fields</strong> in the group by, listing functionally dependent fields there is non-nonsensical and a waste of time.<br> Fortunately MySQL does not require you to do this. </p> <pre><code>$scheduler-&gt;render_table("events LEFT JOIN tblfollowers ON events.id_user = tblfollowers.username WHERE events.status ='active' AND '$test' IN (tblfollowers.follower_id, events.id_user) &lt;&lt;-- maybe faster GROUP BY events.event_id, events.id_user &lt;&lt;-- only include unique key fields ORDER BY events.timestamp DESC" ,"event_id","start_date, start_date,event_name,details"); $scheduler-&gt;render_sql("SELECT event_id, start_date, end_date, event_name, details FROM events "); </code></pre> <p>See here for more info: <a href="http://rpbouman.blogspot.com/2007/05/debunking-group-by-myths.html" rel="nofollow">http://rpbouman.blogspot.com/2007/05/debunking-group-by-myths.html</a> </p> <p><strong>Why is it slow?</strong><br> Without the table definitions for tblfollowers and events it's hard to tell. </p> <p><strong>Use explain</strong><br> If you want to see where the bottleneck is, put an <code>EXPLAIN</code> in front of the select and paste the outcome in your question. </p> <pre><code>$scheduler-&gt;render_sql("EXPLAIN SELECT event_id, start_date, end_date, event_name, details FROM events "); </code></pre> <p><strong>Tacking on indexes does not help</strong><br> Use the output from <code>explain</code> to inform your decisions, adding indexes slows down your inserts and updates, and bloats your disk usage. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload