PDA

View Full Version : Is using large select queries a bad practice


Sensei Eggwoah
01-28-2005, 07:21 PM
First off, I want to say 'ello to all of you. (I'm new)

I have been programming a limited bbs system in php, and I was curious as to how I should approach some of the queries. For example, when I do post counts, should I run a query to count how many posts match the member's id, or will that eventually become slow when alot of topics become posted? I thought that maybe I could just simply update a post count value in the members table and use that. Also on the main page I have it count the number of total posts, and displaying the total number of topics as well as replies. Is this a bad thing? I somehow doubt that if I actually use these scripts, that my bbs will become large, but there is always a chance...

Sorry, I'm semi-new to this stuff. Thanks to anyone who can lend me a hand :)

Kiwi
01-28-2005, 09:02 PM
A count query on an indexed field is usually very fast and you're returning a small result set, so it's nothing to worry about. You would need a lot of data to start taking a noticable performance hit - in the order of millions. By that time, you will have other performance issues and should be looking at archiving old data.

Sensei Eggwoah
01-28-2005, 09:11 PM
Thanks a ton Kiwi! I wanted to make sure that I didn't shoot myself in the foot with my code. :D