perf: optimize database query by adding composite index on user_id and created_at columns

This commit is contained in:
2025-12-03 14:01:02 +00:00
parent 43103e7120
commit 29c8b6d063
11 changed files with 322 additions and 121 deletions
+11 -3
View File
@@ -65,9 +65,17 @@ static const RavaKeyword_t KEYWORDS[] = {
static const size_t KEYWORDS_COUNT = sizeof(KEYWORDS) / sizeof(KEYWORDS[0]);
RavaTokenType_e rava_lexer_lookup_keyword(const char *identifier) {
for (size_t i = 0; i < KEYWORDS_COUNT; i++) {
if (strcmp(identifier, KEYWORDS[i].keyword) == 0) {
return KEYWORDS[i].type;
size_t low = 0;
size_t high = KEYWORDS_COUNT;
while (low < high) {
size_t mid = low + (high - low) / 2;
int cmp = strcmp(identifier, KEYWORDS[mid].keyword);
if (cmp == 0) {
return KEYWORDS[mid].type;
} else if (cmp < 0) {
high = mid;
} else {
low = mid + 1;
}
}
return RAVA_TOKEN_IDENTIFIER;