View Full Version : Which is more efficient?
GLOG
May 26th, 2003, 03:45 PM
php/mysql site... i have admins post news messages. When they log in, i want to show the number of news posts they have posted in total
what is the most efficient way of doing this?
either 1. do a select in the news table by admin and count rows and print this
or
2. every time the admin posts a message increment a counter and store it somewhere in the admin table...
Jubba
May 26th, 2003, 04:09 PM
the first one would probably be the easiest. However I put a counter in almost every table that I make anyway, just because you never really know when you'll need it...
GLOG
May 26th, 2003, 04:21 PM
it isn't a counter in the news table... just a column in the admin table that increments by 1 every time a news post is submitted by that admin
so like
admintable
+--------------------------------------------------------------------
| adminname | adminpassword |adminNumberOfPosts |
| ---------------|----------------------|----------------------------|
| | | |
...
smart idea or no?
its my feeling its more efficient to just be
select adinNumberOfPosts from admintable where admin = admin
rather than
select * from news where admin = admin
count_rows(query)
especially if there is A LOT of news posts
Jubba
May 26th, 2003, 04:23 PM
ohh, I see what you mean. i was a little confuzzled before. yea that would be much more efficient. :)
GLOG
May 26th, 2003, 04:25 PM
yeah :( there's a lot of things i dont know what to let handle... php or sql
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.