Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Shells Virtual Desktop
BMail.ag - Secure Email Service
Server.net
CPLicense.net
VPS Server
Buy VPN
Vultr
VMs for AI
HostDare
HostDare
ReliableSite White-Label Dedicated Hosting for Resellers
25% Recurring Discount on NVMe VPS
InterServer VPS
BMail.ag - Secure Email Service
Best VPN
High-Performance Bare Metal Server Solutions
Karvl.com
Server Mania Cloud Hosting
DataWagon Hosting
AlphaVPS Hosting
Evoxt.com
Clouvider
VPS Hosting with NVMe
Residential IPs in the US & 4G Mobile Proxies in EU & US with Unlimited Bandwidth
ReliableSite White-Label Dedicated Hosting for Resellers
Rabisu - Hosting Solutions
Shells Virtual Desktop
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Counting "tweets", etc

yowmamasitayowmamasita Member
edited January 2013 in Help

I am building a social network site for educational purposes and was wondering how should I efficiently count "tweets" of a user (if for ex. on the tweets table he has 100k entries). Should I do it via SQL Count() or should I add a "no. of tweets" field per user to fetch easily and update it when user add/delete a tweet? Or if there are better approach on this, I'd deeply appreciate your input.

How about the case of counting the total no. of characters of these "tweets"? Is SUM(CHAR_LENGTH(arg)) efficient? Or caching an updated value better?

Let's say these values (no. of tweets and no. of characters for all tweets) are always being called because they are displayed publicly on their profiles.

I am just experimenting on algorithms involving large data, so thanks!

Comments

  • My 2 cents:

    Add the following fields:

    • total numbers tweets
    • total number of published tweets
    • total number of deleted tweets

    This way you can save cpu time with less complex querys.

  • @thekreek said: My 2 cents:

    Add the following fields:

    • total numbers tweets
    • total number of published tweets
    • total number of deleted tweets

    This way you can save cpu time with less complex querys.

    Thanks! Are there any disadvantages in this approach?

  • @yowmamasita said: Are there any disadvantages in this approach?

    Yes. I don't think your database will be normalized and you'll have to be careful about keeping everything in sync.

  • If this is something that's not going to get a ton of traffic, and you don't have a ton of rows (I'm talking millions of rows here), you might as well just count it each time. If you have proper indexes, doing a a COUNT shouldn't take much resources, and you won't have to worry about the count getting out of sync.

Sign In or Register to comment.