FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Speeding up of php page
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Speeding up of php page [message #178943 is a reply to message #178934] Sun, 26 August 2012 22:43 Go to previous messageGo to previous message
Norman Peelman is currently offline  Norman Peelman
Messages: 126
Registered: September 2010
Karma:
Senior Member
On 08/26/2012 01:34 PM, houghi wrote:
> Norman Peelman wrote:
>> #1 - Why are you calling the database twice?
>
> Because I have no idea on how to do it differently. :-(
>

Ok, understandable that you are learning... :) Basically with your
code you are asking the database for all the quote id(s) where the movie
id is a match to your movie, and then saving it to an array ($result).
Might as well grab all the data you're after while you're there the
first time, which is what my code should do.

>> #2 - If you already have the movie id (tconst) then drop the LIKE and
>> just use '='. Using LIKE causes a full table scan, in your example a
>> full table scan is performed 338 times (how big is your db?)
>
> Thanks. phpMyAdmin tells me about quotes:
> ~69,655 total, Query took 0.0003 sec
>

Is this after you created indexes on tconst and qconst? Without those
indexes your times will get significantly worst as you db gets bigger.

>> Set up indexes on qconst and tconst and try:
>>
>> $sql = "SELECT char, nconst, stage, quote FROM quotes WHERE tconst =
>> '$tconst' GROUP BY qconst";
> <snip>
>
> Thanks. Will look into it.
>
>
>> #3
>> I see 4 tables here:
>>
>> movies
>> ------
>>
>> quotes
>> ------
>>
>> person
>> ------
>>
>> character
>> ---------
>>
>> Properly linked, it should only require one call to the database to
>> retrieve your data.
>

It only requires one call now, really.

> Where could I get information about this? What would be the search I
> need to enter into google? The problem is that I learned by copy and
> paste, so I have often no idea what the names are of what I am looking
> for.
>
>
> houghi
>

Search for 'database normalization'.

Look here: http://dev.mysql.com/doc/

And as an example:
http://dev.mysql.com/doc/refman/5.5/en/tutorial.html


--
Norman
Registered Linux user #461062
-Have you been to www.mysql.com yet?-
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Database Abstraction Layer
Next Topic: Using SQLite3 on 1&1 or elsewhere that does not have it installed
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 15:34:31 GMT 2024

Total time taken to generate the page: 0.04172 seconds