We have a Servicestack project that uses Autoquery. In the debug window, I see a number of 2024-12-11 12:51:17.5511|0|DEBUG|OrmLiteReadCommandExtensions|SQL: SELECT * FROM “meta”.“MetaColumnVariationAudit”. Because some of our tables are very big, we are experiencing timeouts. Is there any reason why it selects all records as some of the tables are huge. Is it not possible to derive the table structure based on the information_schema, or by selecting top 1 * from tablename.
Ok looks like this is being called by GetTableSchemas()
from AutoQuery CRUD gen, i.e. it’s being run on Startup to dynamically generate AutoQuery APIs, this should only be done once after which you should switch to code-first dev model so it doesn’t have to regenerate AutoQuery APIs again.
You can also override the implementation of GetTableColumns
it uses to fetch the schema.
appHost.Plugins.Add(new AutoQueryFeature {
MaxLimit = 100,
GenerateCrudServices = new GenerateCrudServices {
// override with custom impl to return `ColumnSchema[]`
GetTableColumns = (IDbConnection db, string table, string schema)
=> db.GetTableColumns($"SELECT TOP 1 * FROM {dialect.GetQuotedTableName(table, schema)}")
}
})
I’ve updated v8.5.3+ that’s now in pre release packages to only select the first row to fetch the table column schemas.
Where would I get the dialect ? When I pasted the code, it shows dialect is invalid ?
Can get it from:
var dialect = db.GetDialectProvider();