Skip to content

Commit

Permalink
Add explain_query
Browse files Browse the repository at this point in the history
  • Loading branch information
surister committed Dec 18, 2024
1 parent 271c387 commit d6b1d1c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
13 changes: 12 additions & 1 deletion src/store/console_store.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Queries from "@/store/http/queries";
import {format_sql} from "@/store/utils";
import {useRoute, useRouter} from "vue-router";
import {use_stored_preferences_store} from "@/store/storedPreferences";
import queries from "@/store/http/queries";


const default_console_response = {
Expand Down Expand Up @@ -48,6 +49,7 @@ export const use_console_store = defineStore('console', () => {
show_full_screen_response: false,
object_representation_mode: true,
history_drawer: false,
analyze: "", // The response of analyze query.
})
const current_console = computed(() => {
if (state.current_console_index >= state.consoles.length) {
Expand Down Expand Up @@ -140,6 +142,14 @@ export const use_console_store = defineStore('console', () => {

}

async function explain_query(analyze=false){
let query = analyze ? queries.EXPLAIN_ANALYZE : queries.EXPLAIN
console.log(current_console.value)
return await request_crate(query, null, {
'%query': current_console.value.content,
})
}

// If there is a ?query=MYQUERY on the url, set it as the current console's content.
if (route.query.query) {
current_console.value.content = route.query.query
Expand Down Expand Up @@ -173,6 +183,7 @@ export const use_console_store = defineStore('console', () => {
add_console,
cancel_current_running_query,
set_console_response_to_empty,
format_query_content
format_query_content,
explain_query
}
})
7 changes: 5 additions & 2 deletions src/store/http/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ export default {
FROM %fs_table
WHERE MATCH ((%fs_columns), '%fs_search_term') USING best_fields
with (fuzziness = %fs_fuzziness)
ORDER BY fs_score DESC LIMIT 15),
ORDER BY fs_score DESC
LIMIT 15),
vec as (SELECT _score, fs_search_id, RANK() over (ORDER BY _score DESC) as vec_rank
FROM %vector_table
WHERE KNN_MATCH("%vector_column", [%vector], %vector_limit)
Expand Down Expand Up @@ -256,7 +257,9 @@ export default {
WITH (fuzziness = 1)
ORDER BY _score DESC
LIMIT 10;
`
`,
EXPLAIN: `EXPLAIN %query`,
EXPLAIN_ANALYZE: `EXPLAIN ANALYZE %query`
}


0 comments on commit d6b1d1c

Please sign in to comment.