when you develop some kind of web app (or sites containing tabular data too) and you need to order “naturally” mysql results, problems starts to come out! googling a lot I’ve found a simple trick that I’m here to share.
- go to: Drupal ViewVC site
- point to / contributions / modules / natsort / natsort.install.mysql.
- download the latest version of the script
- login to your ssh enviroment
- type: mysql – u [username] -p [databasename] < natsort.install.mysql
- insert your corresponding password
- look at your db, now you have 3 new stored procedures, 2 stored functions and 2 new tables:
- Stored Procedures:
- natsort_benchmark
- natsort_finalize
- natsort_initialize
- Stored Functions:
- natsort_canon
- natsort_canon_save
- Tables:
- natsort_lookup
- natsort_lookup_pending
- Stored Procedures:
- you can delete the natsort_initialize() stored procedure. it is used only by drupal, so we don’t need this
- go to Drupal ViewVC site
- Point to / contributions / modules / natsort / README.txt
- follow the simple pass to start using this good workaround.
Don’t forget to call the natsort_finalize() procedure at the end of any query you do. This will speed-up all you next queries.



2 Comments
1 Jun 29, 2008 at 12:10
Daniele Veratti
Good job, man! The only problem i can see about this trick is that you can’t easily apply it to a huge, already written web site (you know what website I mean). You have to rewrite all your SELECT queries in order to use it. Think about it for the next web site I’m going to develop (if any)
PS: Sìì Gruoss!
2 Jun 29, 2008 at 13:22
Giovanni
you can, instead of rewrite all of your queries, modify all views applying natsort to made some rapid improvement to your web app.
Leave a Comment