Previous Thread
Next Thread
Print Thread
Rate Thread
#210772 05/18/2001 3:14 PM
Joined: Feb 2001
Posts: 20
User
User
Offline
Joined: Feb 2001
Posts: 20
Scream -

I have written a script that gets the last 10 written posts from the w3t_posts table.

We would like to display these recently added posts on our main index page, the problem being is that there are 20,000 messages in our database already (we are developing a large system).

My question is this : Is the db smart enough to index these recently added posts efficiently so that they are easily retreived, or is everytime this script runs, the db will traverse through the entire table with some 20,000 entries, looking for the most recent 10 added?

I don't know enough about database design to answer this myself, so please enlighten me. Please describe what the difference between a 'key' and 'index' is, if this is relavent to my question.

We are currenty running PHP version 5.1.6.

Thanks in advance.


= Jim =



= Jim =
Sponsored Links
Joined: May 1999
Posts: 3,039
Guru
Guru
Offline
Joined: May 1999
Posts: 3,039
It really depends on how your query is being run. A good thing to do is drop to a mysql prompt and put DESCRIBE before your query. This will tell you if the query is using an index or not (indexes and keys are basically the same). If it isn't using an index then it will scan the entire table each time.

This may be something you can run in a cron job and spit out a static file as well.


UBB.threads Developer

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
AllenAyres
AllenAyres
Texas
Posts: 21,079
Joined: March 2000
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)