Jump to content

my ViewTopic.php Query,


Baseball

Recommended Posts

Hi everyone, Just wondering if this is a normal query or a query that will kill my database?

 

$DB->query("SELECT s.member_id, s.member_name, s.login_type, s.location, m.desktop,g.g_perm_id, m.org_perm_id
                        FROM ibf_sessions s
                         LEFT JOIN ibf_groups g ON (g.g_id=s.member_group)
                         LEFT JOIN ibf_members m on (s.member_id=m.id)
                        WHERE s.in_topic={$this->topic['tid']}
                        AND s.running_time > $time
                         ORDER BY s.running_time DESC");

 

This is for Active users to display for each topic, [like XX members/guest viewing this topic]

 

Normal or bad?

 

let me know, Thanks!

Link to comment
https://forums.phpfreaks.com/topic/185948-my-viewtopicphp-query/
Share on other sites

Are you trying to customise an IPB forum ? or are you asking if a standard IPB query is written badly ? If it's the latter, I'd imagine IPB know enough about what they're doing and their database schema to write a well performing query.

 

Just if it's written badly.

Without seeing IPB's database schema I couldn't tell you, but with that said I run a large forum (110,000+ members, 1million+ posts) on vbulletin and I am considering a switch to IPB. I rate them highly, and have confidence in their coding.

 

If your host is complaining about cpu/memory usage because of that particular query it is likely you may have just outgrown their hosting package (assuming you're using a shared host). You can probably turn off WOL for topic views if you wanted. You can in vbulletin and it's often recommended when experiencing high server loads.

Without seeing IPB's database schema I couldn't tell you, but with that said I run a large forum (110,000+ members, 1million+ posts) on vbulletin and I am considering a switch to IPB. I rate them highly, and have confidence in their coding.

 

If your host is complaining about memory usage because of that particular query it is likely you may have just outgrown their hosting package (assuming you're using a shared host). You can probably turn off WOL for topic views if you wanted. You can in vbulletin and it's often recommended when experiencing high server loads.

 

I have a highly customized Ipb 1.3, :-)

 

I run on shared hosting 2.99$/month with over 100 Users online... and i only use up half bandwidth/month..

 

 

But I was just wondering why the hell it Left joins a Groups table and my ibf members table again? i think just to match the id so it can spit out the username, but i'd rather insert that before, instead of calling a whole table,

 

Is it calling my whole ibf_members? or just what it needs? Cause if it's calling my WHOLE ibf_members that's not good cause it's over 100 rows.

 

It will be calling what it needs, and it's making that call by filtering/joining primary keys so should be as fast as it can be.

 

It is filtering your members table by which members have an active session in the sessions table. It is also then getting the groups by users it has ascertained from the previous filter.

 

If that isn't clear enough let me know.

It will be calling what it needs, and it's making that call by filtering/joining primary keys so should be as fast as it can be.

 

It is filtering your members table by which members have an active session in the sessions table. It is also then getting the groups by users it has ascertained from the previous filter.

 

I understand now, Thank you.

 

I  am going to make a lot of cuts into my Ibf_members row .. I have alot of useless row fields that arn't being used at all.

 

Lol, sorry it's just I am so picky when it comes to Coding.. (I guess that can be a good thing?)

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.