
Do you train Kung Fu?
Or know someone who does?
Then check out KungFuPeople.com
Mobile version of this pageCareful when dealing with options in IE
Next:
Best bicycle locks
Related blogs
PostgreSQL, MySQL or SQLiteLoadtesting this site and compare with static Apache
Optimized stylesheets
Adding a year in PostgreSQL
Creating a user for postgresql
More optimization of Peterbe.com - CSS sprites
Speed test between django_mongokit and postgresql_psycopg2
Sorting transform function in PostgreSQL
Gzip and Slimmer optimization anecdote
rfc822() vs. rfc1123_date()
The problem with CSS
ALTER TABLE patch
Running simple SQL commands on the command line
Integer division in programming languages
Date formatting in python or in PostgreSQL
pg_class to check if table exists
List of casts in PostgreSQL
Just Oracle and IBM?
Quick PostgreSQL optimization story
To sub-select or not sub-select in PostgreSQL
Why bother with MySQL...
Fastest way to uniqify a list in Python
To $('#foo p') or to $('p', $('#foo'))
Nice date input
Formatting numeric amounts in Javascript
Python optimization anecdote
Related by category
Date formatting in Python or in PostgreSQL (part II)
postgresql, benchmark, datetime, formatting, time_stamp, to_char, optimization
19th of April 2006
This is an update on Date formatting in python or in PostgreSQL where the test wasn't done very well. The solution using Python for the formatting created a new DateTime object each time for each formatting because the time_stamp extracted from the database was a string. That would be beneficial to the Python formatting alternative but that's not the whole point. I suspect that the way I did the experiment last time (code is lost by the way) was wrong and didn't focus on the correct benchmark.
In this, my second attempt, I've done a more correct test and tried it on 500 selects. 500 formatted in SQL and 500 formatted in Python. The results are even more outstanding for PostgreSQL than last time.
Here are the results:
times1 (python formatted) 0.113439083099 times2 (sql formatted) 0.00697612762451
That means that doing the date formatting in SQL is 16 times faster!!
Bare in mind that this is optimization and you always have to be careful when doing optimization. For example, the SQL database shouldn't get involved in the presentation and if you need to use a different locale you might to change your application in two places which is risky.


Save this page in del.icio.us