2008/07/21

Definition of "Lock wait ratio"

When "tuner-primer.sh" under MySQL is used, "Lock wait ratio" appears at the end of the report.
Here is the explanation of Lock wait ratio:
A metric that attempts to quantify the percentage of queries that are required to wait for object locks to be released so that the query can itself acquire a lock on the object.

2008/07/12

Let Django work with view cache

  1. Modify django/utils/decorators.py

    --- django/utils/decorators.py (revision 4490)

    +++ django/utils/decorators.py (working copy)

    @@ -30,4 +30,12 @@

    return result

    return response

    return _wrapped_view

    +

    + def _true_24_decorator(*args, **kwargs):

    + def _decorator(f):

    + return _decorator_from_middleware(f, *args, **kwargs)

    + return _decorator

    +

    + _decorator_from_middleware.decorator = _true_24_decorator

    +

    return _decorator_from_middleware

  2. Usage:

    @cache_page.decorator(60)

    def my_cool_view(request):

    # cool processing

2008/07/08

Install Mysql with non root account on linux system.

Download mysql server at http://dev.mysql.com/downloads/mysql/
Run it directly.

OneToOne relations in Elixir

Note that a OneToOne relationship cannot exist without a corresponding ManyToOne relationship in the other way. This is because the OneToOne relationship needs the foreign_key created by the ManyToOne relationship.
When an OneToOne relation is needed, you need to make ManyToOne relationship first, where in database foreign keys are stored.

Example:

class Movie(Entity):
using_options(tablename='Movie',autosetup=True)
title=Field(Unicode(30))
year=Field(Integer)
decription=Field(Unicode)
director=ManyToOne('Director')

class Director(Entity):
using_options(tablename='Director',autosetup=True)
name=Field(Unicode(60))
movie=OneToOne('Movie')

Release memory when using SqlAlchemy for a long time contextual session

First
session.flush()
then
session.close()

The close() method issues a clear(), and releases any transactional/connection resources. When connections are returned to the connection pool, whatever transactional state exists is rolled back.

When close() is called, the Session is in the same state as when it was first created, and is safe to be used again. close() is especially important when using a contextual session, which remains in memory after usage. By issuing close(), the session will be clean for the next request that makes use of it.

New Group Webpage is on line written by Django

http://biocroma.uzh.ch

It is a django site. Django is very good and fast developing.

Join example in SQLalchemy

We have 2 tables

CREATE TABLE `zincnew01`.`zincmol` ( `zincid` int(8) unsigned NOT NULL, `pacname` char(3) NOT NULL, `numatoms` tinyint(3) unsigned NOT NULL, `numc` tinyint(3) unsigned NOT NULL, `numn` tinyint(3) unsigned NOT NULL, `numo` tinyint(3) unsigned NOT NULL, `numhal` tinyint(3) unsigned NOT NULL, `nums` tinyint(3) unsigned NOT NULL, `nump` tinyint(3) unsigned NOT NULL, `numarombnd` tinyint(3) unsigned NOT NULL, `numdoubbnd` tinyint(3) unsigned NOT NULL, `numtribnd` tinyint(3) unsigned NOT NULL, `numamibnd` tinyint(3) unsigned NOT NULL, `numacc` tinyint(3) unsigned NOT NULL, `numdon` tinyint(3) unsigned NOT NULL, `numring` tinyint(3) unsigned NOT NULL, `totringsize` tinyint(3) unsigned NOT NULL, `longestchain` tinyint(3) unsigned NOT NULL, `wienerind4` float(16,14) NOT NULL, `numbnd` tinyint(3) unsigned NOT NULL, `numfrg` tinyint(3) unsigned NOT NULL, `numrotbnd` tinyint(3) unsigned NOT NULL, `mw` float(8,3) unsigned NOT NULL, `clogp` float(5,2) NOT NULL, `charge` int(2) NOT NULL, `mol2file` blob, `tag` char(20) default NULL, PRIMARY KEY (`zincid`), KEY `pacname` (`pacname`), KEY `tag` (`tag`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1

and

CREATE TABLE `zincnew01`.`Pose` ( `id` int(11) NOT NULL auto_increment, `pose` int(4) default NULL, `ele` float default NULL, `elee` float default NULL, `vdw` float default NULL, `vdwe` float default NULL, `pdbfile` blob, `mol_zincid` int(8) unsigned default NULL, `tag` char(20) default NULL, PRIMARY KEY (`id`), KEY `ix_Pose_mol_zincid` (`mol_zincid`) ) ENGINE=MyISAM AUTO_INCREMENT=39261434 DEFAULT CHARSET=latin1

I want to query lile select * from Pose,zincmol where zincid=mol_zincid and pacname="xaa" In SQLalchemy (elixir) I use Pose.query.filter(Pose.tag==None).join('mol').filter(Mol.pacname=='xaa') to get the same results.