On Tue, Feb 12, 2013 at 11:29 AM, shaung <shaun.g...@gmail.com> wrote:
> On Tuesday, February 12, 2013 7:18:37 PM UTC+9, Simon King wrote:
>>
>> If you add echo='debug' to your create_engine call, SA will log all
>> calls to the database and rows returned, which might give you an idea
>> of where all the time is being spent.
>>
>
> Thanks, Simon. I've looked through the debug log and found the reason.
>
> It turns out that the table has several foreign key constraints,
> and SA is inspecting all of the related tables and all the related tables to
> the related tables...
> There were 23 tables involved, which explained the long execution time.
>
> So is there anything I can do about this?
> I'm considering two possibilities:
>
> 1. Ignore the constraints to speed up
> 2. Or cache all the meta data to a disk file so no need to wait when
> restarting the program
>
> Either would be fine for me.
> Is it possible?
>

Caching the metadata should be fairly easy if you are happy with that
approach. I think MetaData instances are picklable:

  
http://stackoverflow.com/questions/11785457/sqlalchemy-autoloaded-orm-persistence

Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to