On Mon, Jul 14, 2008 at 6:12 PM, fordprefect <[EMAIL PROTECTED]> wrote:

>
> We have been optimizing our server (db and caching) since our recent
> launch and one thing we've been looking at is our server status:
>
> Total queries: 4,307,827
> Com_admin_commands: 3,754,356
> Com_insert: 37,790
> Com_select: 1,354,134
> Com_set_option: 172,319
> Com_update: 52,759
> Com_commit: 88,107
>
> (this is approx over 10 hours uptime, 10K visitors/day).
>
> Running Django trunk, mysql Ver 14.12 Distrib 5.0.32, python 2.5,
> Debian.
>
> The com_admin_commands seems extremely high. I have tested on another
> machine with similar setup and can confirm that almost every SELECT
> run through the Django ORM (and possibly INSERT/UPDATE/DELETE) is
> running a com_admin_command. Running queries separately on MySQL or
> through connection.cursor() do not cause this.
>

com_admin_commands includes COM_PING, which is issued every time the MySQL
backend is called to retrieve a cursor for an existing connection.
Internally it looks like Django gets a cursor pretty much immediately before
executing any SQL.  So any hit to the database (after the connection is
first established) is probably incrementing con_admin_commands.


>
> For example:
> from django.contrib.auth.models import User
> u = User.objects.get(pk=1)
>
> will cause an increase in com_admin_commands but not
>
> from django.db import connection
> c=connection.cursor()
> c.execute("select * from auth_user")
>

If you try this 2nd sequence multiple times, you will see that the
connection.cursor() call causes an increment of com_admin_commands (it does
not the first time because during that call a connection is established).
Django internally does the connection.cursor() immediately before each
execute(), so com_admin_commands gets incremented a lot.


> I have 3 questions:
> 1) Have other django/mysql developers encountered this?
> 2) Have they encountered perfomance issues as a result ?
> 3) Which command (if any) is being fired to cause an increase in
> com_admin_commands ?
>

Yes, I see the same behavior.  Whether doing this ping before each SQL
execute is a significnat performance hit I don't know.  It seems a bit
wasteful, but the time involved could easily be just noise compared to the
time required for real work that has to get done for each SQL execute.
You'd need to get some profiling data or experiment with removing it to see
what its measurable cost is.

Karen

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to