Jump to content

Archived

This topic is now archived and is closed to further replies.

moonbeachx

Accessing my Table via Index

Recommended Posts


Hi,

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".

Help!

Share this post


Link to post
Share on other sites
"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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.