Geert,
Just for the record, I use the "SQL initial data file" feature that
Adrian mentioned to enable full-text indexing on a couple of my tables.
The relevant part of my script is:
ALTER TABLE data_rawtrade ENGINE=MyISAM;
CREATE FULLTEXT INDEX ix_ft_data_rawtrade_all
ON data_rawtrade (tradeType, investIdType, investId, portfolio,
book, strategy,
counterparty, custodian, account);
CREATE FULLTEXT INDEX ix_ft_data_rawtrade_intalloc
ON data_rawtrade (portfolio, book, strategy);
CREATE FULLTEXT INDEX ix_ft_data_rawtrade_extalloc
ON data_rawtrade (counterparty, custodian, account);
It all works fine, of course I need to use custom SQL to actually do a
full-text search, but that's no biggie.
There are two suggestions I would make regarding this feature to
improve it a bit:
1) In addition to providing initial data in a file
<appname>/sql/<modelname>.sql, I think it would be good to support a
form of <appname>/sql/<backend>/<modelname>.sql so if you want to put
DB-specific stuff in there you can. That way if I moved my app to
PostgreSQL, for example, it wouldn't try to execute the SQL (which
would break)
2) While there is a get_in_bulk() method in the DB api, for cases like
full-text indexing, I think it would be more useful to have a
get_from_cursor() or something like that where you could just use
custom SQL to do whatever query you needed (i.e. "select * from
data_rawtrade where match(portfolio,book,strategy) against('hedge')")
and load the resulting objects directly from the cursor. It seems a bit
wasteful to do a "select id from ...", get the IDs, and then call
get_in_bulk() (2 DB hits and a potentially gnarly "in" clause depending
on how many objects you found with your search).
-Dave
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---