Jump to content


Accessing my Table via Index

  • Please log in to reply
1 reply to this topic

#1 moonbeachx

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 13 February 2006 - 03:12 AM


I am a newbie to PHP database programming. I have spent all day looking for a way to speed up a query that is over a table with 6 million (and counting) rows.

Indexes seem like the way to go, so I created an index over my table. The table is Foo1 and the index is Foo2

Now in my PHP Select statement do I just substitude Foo2 everywhere I had Foo1? I did so, and it gave me lots of errors:

"Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/voletus/public_html/pages/property_poss17g.php on line 55".


#2 fenway

  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 13 February 2006 - 03:40 AM

"Index over my table?" No, I think you're a bit confused. Your table name doesn't change, so keep foo1 in your queries, otherwise all hell will break loose. Second, I don't know what you mean by "the index is foo2" -- sure, you could give it that name, but the name is totally irrelevant, as you (almost) never need to use it. A proper index will be automagically picked by the mysql optimizer during parsing.

What kind of index did you add? What type of queries are running slowly? What's the table structure? What type of read/write operations are being performed on this table? These are the types of questions we'll need answers to in order to help.

But at its simplest, adding an index to a table doesn't change the syntactic nature of the query that it (possibly) affects.

Hope that makes sense -- post back with the answers to the above questions, and we'll take it from there.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users