Hello! We're running a unit test that includes constructing ≈330 tables & ≈2,000 columns total in a local PostgreSQL 10.13 database (on disk, not in memory). After profiling the test, we found that it takes ≈4 seconds to create all of the SQLAlchemy `Mapper` objects [0], which are currently a prerequisite to running the test. This time doesn't include emitting any SQL -- just constructing the in-memory python mapper objects.
So, my questions are: 1. Is this performance about expected for the number of tables & columns? Or does it point to something we may be doing wrong? 2. Are there any tips or tricks for structuring tests so that a single test that requires the database schema runs quickly? I read through the "Testing" section <https://www.oreilly.com/library/view/essential-sqlalchemy-2nd/9781491916544/ch04.html> of Essential SQLAlchemy, and we'd like to avoid mocking, if possible. As far as due diligence goes, I read through the Performance FAQ <https://docs.sqlalchemy.org/en/13/faq/performance.html>, but I didn't see a mention of debugging slowness initializing the mapper objects, and I found this StackOverflow post <https://stackoverflow.com/a/50823545/584663> re: mapping slowness in the application server, but that's not my primary concern. Versions: PostgreSQL 10.13 SQLAlchemy 1.3.20 Happy to provide more details if you think they'd be helpful. Thanks, Bill [0] https://github.com/sqlalchemy/sqlalchemy/blob/rel_1_3_20/lib/sqlalchemy/ext/declarative/api.py#L74 https://github.com/sqlalchemy/sqlalchemy/blob/rel_1_3_20/lib/sqlalchemy/ext/declarative/base.py#L695-L697 (we don't set "__mapper_cls__" on any classes, so we're using the default `mapper`) -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/1958022d-e679-4d9f-b2de-91ef7926dde9n%40googlegroups.com.
