@mastra/pg 0.17.1 → 0.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/index.cjs +62 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +62 -55
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/operations/index.d.ts +6 -1
- package/dist/storage/domains/operations/index.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -3124,65 +3124,72 @@ var StoreOperationsPG = class extends StoreOperations {
|
|
|
3124
3124
|
}
|
|
3125
3125
|
}
|
|
3126
3126
|
/**
|
|
3127
|
-
*
|
|
3127
|
+
* Returns definitions for automatic performance indexes
|
|
3128
3128
|
* These composite indexes cover both filtering and sorting in single index
|
|
3129
3129
|
*/
|
|
3130
|
+
getAutomaticIndexDefinitions() {
|
|
3131
|
+
const schemaPrefix = this.schemaName ? `${this.schemaName}_` : "";
|
|
3132
|
+
return [
|
|
3133
|
+
// Composite index for threads (filter + sort)
|
|
3134
|
+
{
|
|
3135
|
+
name: `${schemaPrefix}mastra_threads_resourceid_createdat_idx`,
|
|
3136
|
+
table: TABLE_THREADS,
|
|
3137
|
+
columns: ["resourceId", "createdAt DESC"]
|
|
3138
|
+
},
|
|
3139
|
+
// Composite index for messages (filter + sort)
|
|
3140
|
+
{
|
|
3141
|
+
name: `${schemaPrefix}mastra_messages_thread_id_createdat_idx`,
|
|
3142
|
+
table: TABLE_MESSAGES,
|
|
3143
|
+
columns: ["thread_id", "createdAt DESC"]
|
|
3144
|
+
},
|
|
3145
|
+
// Composite index for traces (filter + sort)
|
|
3146
|
+
{
|
|
3147
|
+
name: `${schemaPrefix}mastra_traces_name_starttime_idx`,
|
|
3148
|
+
table: TABLE_TRACES,
|
|
3149
|
+
columns: ["name", "startTime DESC"]
|
|
3150
|
+
},
|
|
3151
|
+
// Composite index for evals (filter + sort)
|
|
3152
|
+
{
|
|
3153
|
+
name: `${schemaPrefix}mastra_evals_agent_name_created_at_idx`,
|
|
3154
|
+
table: TABLE_EVALS,
|
|
3155
|
+
columns: ["agent_name", "created_at DESC"]
|
|
3156
|
+
},
|
|
3157
|
+
// Composite index for scores (filter + sort)
|
|
3158
|
+
{
|
|
3159
|
+
name: `${schemaPrefix}mastra_scores_trace_id_span_id_created_at_idx`,
|
|
3160
|
+
table: TABLE_SCORERS,
|
|
3161
|
+
columns: ["traceId", "spanId", "createdAt DESC"]
|
|
3162
|
+
},
|
|
3163
|
+
// AI Spans indexes for optimal trace querying
|
|
3164
|
+
{
|
|
3165
|
+
name: `${schemaPrefix}mastra_ai_spans_traceid_startedat_idx`,
|
|
3166
|
+
table: TABLE_AI_SPANS,
|
|
3167
|
+
columns: ["traceId", "startedAt DESC"]
|
|
3168
|
+
},
|
|
3169
|
+
{
|
|
3170
|
+
name: `${schemaPrefix}mastra_ai_spans_parentspanid_startedat_idx`,
|
|
3171
|
+
table: TABLE_AI_SPANS,
|
|
3172
|
+
columns: ["parentSpanId", "startedAt DESC"]
|
|
3173
|
+
},
|
|
3174
|
+
{
|
|
3175
|
+
name: `${schemaPrefix}mastra_ai_spans_name_idx`,
|
|
3176
|
+
table: TABLE_AI_SPANS,
|
|
3177
|
+
columns: ["name"]
|
|
3178
|
+
},
|
|
3179
|
+
{
|
|
3180
|
+
name: `${schemaPrefix}mastra_ai_spans_spantype_startedat_idx`,
|
|
3181
|
+
table: TABLE_AI_SPANS,
|
|
3182
|
+
columns: ["spanType", "startedAt DESC"]
|
|
3183
|
+
}
|
|
3184
|
+
];
|
|
3185
|
+
}
|
|
3186
|
+
/**
|
|
3187
|
+
* Creates automatic indexes for optimal query performance
|
|
3188
|
+
* Uses getAutomaticIndexDefinitions() to determine which indexes to create
|
|
3189
|
+
*/
|
|
3130
3190
|
async createAutomaticIndexes() {
|
|
3131
3191
|
try {
|
|
3132
|
-
const
|
|
3133
|
-
const indexes = [
|
|
3134
|
-
// Composite index for threads (filter + sort)
|
|
3135
|
-
{
|
|
3136
|
-
name: `${schemaPrefix}mastra_threads_resourceid_createdat_idx`,
|
|
3137
|
-
table: TABLE_THREADS,
|
|
3138
|
-
columns: ["resourceId", "createdAt DESC"]
|
|
3139
|
-
},
|
|
3140
|
-
// Composite index for messages (filter + sort)
|
|
3141
|
-
{
|
|
3142
|
-
name: `${schemaPrefix}mastra_messages_thread_id_createdat_idx`,
|
|
3143
|
-
table: TABLE_MESSAGES,
|
|
3144
|
-
columns: ["thread_id", "createdAt DESC"]
|
|
3145
|
-
},
|
|
3146
|
-
// Composite index for traces (filter + sort)
|
|
3147
|
-
{
|
|
3148
|
-
name: `${schemaPrefix}mastra_traces_name_starttime_idx`,
|
|
3149
|
-
table: TABLE_TRACES,
|
|
3150
|
-
columns: ["name", "startTime DESC"]
|
|
3151
|
-
},
|
|
3152
|
-
// Composite index for evals (filter + sort)
|
|
3153
|
-
{
|
|
3154
|
-
name: `${schemaPrefix}mastra_evals_agent_name_created_at_idx`,
|
|
3155
|
-
table: TABLE_EVALS,
|
|
3156
|
-
columns: ["agent_name", "created_at DESC"]
|
|
3157
|
-
},
|
|
3158
|
-
// Composite index for scores (filter + sort)
|
|
3159
|
-
{
|
|
3160
|
-
name: `${schemaPrefix}mastra_scores_trace_id_span_id_created_at_idx`,
|
|
3161
|
-
table: TABLE_SCORERS,
|
|
3162
|
-
columns: ["trace_id", "span_id", "created_at DESC"]
|
|
3163
|
-
},
|
|
3164
|
-
// AI Spans indexes for optimal trace querying
|
|
3165
|
-
{
|
|
3166
|
-
name: `${schemaPrefix}mastra_ai_spans_traceid_startedat_idx`,
|
|
3167
|
-
table: TABLE_AI_SPANS,
|
|
3168
|
-
columns: ["traceId", "startedAt DESC"]
|
|
3169
|
-
},
|
|
3170
|
-
{
|
|
3171
|
-
name: `${schemaPrefix}mastra_ai_spans_parentspanid_startedat_idx`,
|
|
3172
|
-
table: TABLE_AI_SPANS,
|
|
3173
|
-
columns: ["parentSpanId", "startedAt DESC"]
|
|
3174
|
-
},
|
|
3175
|
-
{
|
|
3176
|
-
name: `${schemaPrefix}mastra_ai_spans_name_idx`,
|
|
3177
|
-
table: TABLE_AI_SPANS,
|
|
3178
|
-
columns: ["name"]
|
|
3179
|
-
},
|
|
3180
|
-
{
|
|
3181
|
-
name: `${schemaPrefix}mastra_ai_spans_spantype_startedat_idx`,
|
|
3182
|
-
table: TABLE_AI_SPANS,
|
|
3183
|
-
columns: ["spanType", "startedAt DESC"]
|
|
3184
|
-
}
|
|
3185
|
-
];
|
|
3192
|
+
const indexes = this.getAutomaticIndexDefinitions();
|
|
3186
3193
|
for (const indexOptions of indexes) {
|
|
3187
3194
|
try {
|
|
3188
3195
|
await this.createIndex(indexOptions);
|