# Which is more efficient?

**URL:** https://forum.kirupa.com/t/which-is-more-efficient/21815
**Category:** Uncategorized
**Created:** [May 26, 2003, 7:45pm UTC](https://forum.kirupa.com/t/which-is-more-efficient/21815 "2003-05-26T19:45:43Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![GLOG](https://avatars.discourse-cdn.com/v4/letter/g/7c8e57/32.png) [@GLOG](https://forum.kirupa.com/u/GLOG)
#### Post date: [May 26, 2003, 7:45pm UTC](https://forum.kirupa.com/t/which-is-more-efficient/21815/1 "2003-05-26T19:45:43Z")

</div>

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…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 26, 2003, 8:09pm UTC](https://forum.kirupa.com/t/which-is-more-efficient/21815/2 "2003-05-26T20:09:49Z")

</div>

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…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 26, 2003, 8:21pm UTC](https://forum.kirupa.com/t/which-is-more-efficient/21815/3 "2003-05-26T20:21:35Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 26, 2003, 8:23pm UTC](https://forum.kirupa.com/t/which-is-more-efficient/21815/4 "2003-05-26T20:23:38Z")

</div>

ohh, I see what you mean. i was a little confuzzled before. yea that would be much more efficient. 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 26, 2003, 8:25pm UTC](https://forum.kirupa.com/t/which-is-more-efficient/21815/5 "2003-05-26T20:25:36Z")

</div>

yeah ☹ there’s a lot of things i dont know what to let handle… php or sql
