@clickup/pg-microsharding
Version:
Microshards support for PostgreSQL
27 lines (24 loc) • 570 B
text/typescript
import type { TableInfo } from "./getTablesInSchema";
import { ident, join, sql } from "./quote";
import { runSqlProgressNonTransactional } from "./runSqlProgress";
export async function analyzeTables({
toDsn,
tables,
}: {
toDsn: string;
tables: TableInfo[];
}): Promise<void> {
if (tables.length === 0) {
return;
}
await runSqlProgressNonTransactional(
toDsn,
join(
tables.map(
({ schema, name }) => sql`ANALYZE ${ident(schema)}.${ident(name)};`,
),
"\n",
),
"Running ANALYZE for the copied tables",
);
}