views:

343

answers:

4

I'm using TopLink as my ORM and MySQL as the DB.

I traded my auto-increment primary keys for GUIDs for one of my tables (alright, not quite: I'm actually using a random 64 bit integer, but that's good enough for my needs).

Anyway, now queries, which don't even use the key, are taking much longer.

What can I do?

+1  A: 

If your table is indexed by the fields your are querying by. content of the key shouldn't have any noticeable performance impact. They maybe something else there .

Kozyarchuk
i have a field that represents the creationDate. how can i force my table to be index accordingly?
carrier
i think you are right, there must be something else.
carrier
+1  A: 

Make sure the key column really is the PRIMARY KEY and thus the clustered (physical) index.

Make sure you have indexes that hit your common queries.


Random integer? You realize there's a chance of hitting the same pri key?

Aidan Ryan
Lets hope that he doesn't have a bad PRNG and accidentally get the same seed, so he has to test all keys over and over...
some
primary key is clustered only if he's using innodb.
le dorfier
A: 

i have a field that represents the creationDate. how can i force my table to be index accordingly?

create index Table_creationDate on Table(creationDate);
Frank Krueger
What do you mean by "force my table to index"? That's not a database concept I'm familiar with.
le dorfier
i guess i just meant create an indexwhat Frank Krueger answered was helpful
carrier
+1  A: 

If you're using innodb tables in MySQL all rows are referred to by primary key so if you're using a secondary key performance will suffer.

Cory House