Welcome Guest, Not a member yet? Register   Sign In
Issue with arrays? Any experts?
#11

[eluser]Devon Lambert[/eluser]
[quote author="gtech" date="1211865300"]
also I am hoping that the category name is unique? if not you should be using an ID..
[/quote]

The category names are unique gtech, but is there really a performance gain to be had by using the "id" field as opposed to the "name" field?

I am running off of pre - existing code in my rebuild of the site so I am more than happy to make performance changes now.

[quote author="gtech" date="1211865300"]
there are cleaner methods of achieving what you want but lets do one step at a time.
[/quote]

cleaner huh? do tell. :cheese:
#12

[eluser]oddman[/eluser]
Yes, definitely faster - MUCH faster. Considering you're using cat in the where clause and it's a string - your indexes (if you have any defined), are string-based. Numerical indexes are a billion times faster (okay maybe not that much) Tongue

As for cleaning it up, it's possible to do what you want as part of a single query and/or store the data as a tree.
#13

[eluser]gtech[/eluser]
[strike]no massive performance gain (unless your database is huge, I have no real timing stats though)[/strike][edit]don't have evidence to contradict[/edit]

Just wanted to ensure your name field was unique as the code would fall over if it was not. not to worry in your case, the general rule of thumb is to use ids, then someone can change the name if they want to.

well you could have one function to build up the items array and the categories array rather than splitting it in to two, but its not broken so lets not fix it Smile.

p.s. turning of db_debug is the biggest performance enhancement you can make.
#14

[eluser]Devon Lambert[/eluser]
[quote author="gtech" date="1211873538"][strike]no massive performance gain (unless your database is huge, I have no real timing stats though)[/strike][edit]don't have evidence to contradict[/edit]

Just wanted to ensure your name field was unique as the code would fall over if it was not. not to worry in your case, the general rule of thumb is to use ids, then someone can change the name if they want to.

well you could have one function to build up the items array and the categories array rather than splitting it in to two, but its not broken so lets not fix it Smile.

p.s. turning of db_debug is the biggest performance enhancement you can make.[/quote]

Hmmm well the "games"/"items" table has about 2,500 rows and it will grow substantially (could go as high as 5000 by year end) in the future. Category table only has 7 rows. Do you think changing the identifier from the cat name to id is worth it in this case. I could easily add another column in the games table for "cat_id" and run my queries based on that value instead of "cat_name". The question is, is it truly worth it in this case?

p.s. Thanks for all the help today by the way. (You too oddman!)
#15

[eluser]oddman[/eluser]
If that's the case, I would be linking them by ID, not by name. Besides the lack of database normalization (name existing in more than one place), it will get quite slow having to search as a string, especially over 5000 records.
#16

[eluser]Devon Lambert[/eluser]
OK ok... I can tell when the voice of the reason has spoken.

I went ahead and updated the database and the functions.

Thanks for the great advice again.




Theme © iAndrew 2016 - Forum software by © MyBB