Manuscript Offprint
arXiv:2610.32586OCTOPUS: Towards A Tag Model for Cross-Query Reuse in Semantic Query Processing
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
GuangXue Zhang
University of California, Irvine
Irvine, USA
Nada Lahjouji
Blizzard Inc
Irvine, USA
Yiming Lin
University of California, Berkeley
Berkeley, USA
Ashwin Colaco
University of California, Irvine
Irvine, USA
ABSTRACT
Large language models make it possible to pose semantic questions over diverse, multi-modal data. Recent systems give such workloads the declarative feel of a database through semantic operators: relational operators whose conditions a model judges. Most of them now run on a relational engine, yet almost none keeps what the model says past the query: every judgment is discarded on completion and paid for again the next time a query needs it. We present the tag model and tag operators, the right unit for semantic processing, and OCTOPUS, a prototype built as a middleware over DBMS. Two mechanisms are central. First, the tag: each semantic answer a model produces is written back to the relation as data, which the database engine filters, indexes, and stores as it would any other. Second, the tag operator: the unit into which common semantic operators are translated, which fixes the granularity of reuse. A model judges a tuple once, and later queries reuse that judgment as data: through relationships between predicates, a stored judgment can accept a tuple for a later predicate, eliminate one that cannot satisfy it, simplify its test, or order the search of a query that stops early. On the movie scenario of SemBench, our prototype sends the model 10 to 108× fewer rows than iPDB, ThalamusDB, Palimpzest, and LOTUS at broadly competitive quality, and three of its eight queries issue no model call at all. More broadly, a database that keeps its judgments lets its schema grow from the questions its users ask, so that each semantic answer is paid for once, stays consistent across queries, and can be audited through its provenance.
PVLDB Reference Format:
GuangXue Zhang, Nada Lahjouji, Yiming Lin, Ashwin Colaco, and Sharad Mehrotra. OCTOPUS: Towards A Tag Model for Cross-Query Reuse in Semantic Query Processing [Vision]. PVLDB, 20(1): XXX-XXX, 2027. doi:XX.XX/XXX.XX
PVLDB Artifact Availability:
The source code, data, and/or other artifacts have been made available at https://github.com/Delilah1230/octopus_vision.
Sharad Mehrotra
University of California, Irvine
Irvine, USA
1 INTRODUCTION
Large language models make it possible to evaluate, at query time, a class of conditions relational databases cannot support: predicates whose satisfaction is computed over the meaning of unstructured content rather than typed values. Consider applications that hold large collections of multi-modal data, such as Amazon, whose catalogue carries product descriptions, customer reviews along with pictures, or Netflix, whose movies carry synopses and trailers. Given the number of customers such platforms serve, the questions asked on them cannot be anticipated. Users phrase questions in their own terms, so the set of predicates a workload will eventually ask is unbounded and unknown when the schema is designed. A customer may search Amazon for “a Christmas-themed gift that suits my grandparents”, or parents may look for “a comedy that adults enjoy but is still suitable for young children”. No column of either schema records whether a product is Christmas-themed or whether a film is suitable for children. Instead, a model such as an LLM analyzes the question on the fly and judges which products or movies semantically satisfy it.
Although such questions rarely repeat literally, the judgments their predicates require often overlap: gift and holiday themes return every holiday season, and family-suitable films are asked for by other families as well. An LLM agent that answers each question in isolation cannot exploit this overlap. The agent retains nothing between queries, so every semantic judgment is discarded on completion and paid for again the next time it is needed, and none of the pruning and reordering a database optimizer would apply is available to it. Semantic operator systems answer such questions with relational-style operators (filter, map, join) whose condition is written in natural language and judged by an LLM.
We compare recent semantic operator systems in Table 1 from four angles: planner-level optimization, operator-level optimization, whether the system is built upon a DBMS, and whether it caches model results. Among the systems listed in Table 1, only LOTUS [25] and Palimpzest [23] are built as standalone engines, while the others build their semantic operators upon a DBMS (inside DuckDB [27] or Snowflake [8], as UDFs, or as a layer over DuckDB). The last column compares whether a system caches model results; iPDB [18], PLOP [24], and FlockMTL [11] do, but only for duplicate tuples within a query, and a cross-query cache is provided by LOTUS and AIDB [14], under the constraint of an identical prompt, which limits the use case.
This work is licensed under the Creative Commons BY-NC-ND 4.0 International License. Visit https://creativecommons.org/licenses/by-nc-nd/4.0/ to view a copy of this license. For any use beyond those covered by this license, obtain permission by emailing info@vldb.org. Copyright is held by the owner/author(s). Publication rights licensed to the VLDB Endowment.
Proceedings of the VLDB Endowment, Vol. 20, No. 1 ISSN 2150-8097. doi:XX.XX/XXX.XX
Table 1: Comparison of current representative semantic query processing systems. Planner: plan-level optimization. SemOps: semantic operator-level optimization. DB-based: integration with a relational DBMS. Cache: caching of semantic inference results. Circles denote full, partial, and no support.
| Planner | SemOps | DB-based | Cache | |
|---|---|---|---|---|
| LOTUS [25] | ○ | ● | ○ | ① |
| Palimpzest [23] | ● | ○ | ○ | ○ |
| iPDB [18] | ① | ① | ● | ① |
| PLOP [24] | ● | ○ | ① | ① |
| ThalamusDB [15] | ① | ① | ① | ○ |
| FlockMTL [11] | ○ | ● | ① | ① |
| Sema [26] | ● | ① | ● | ○ |
| Sema-SQL [21] | ● | ① | ① | ○ |
| Cortex AISQL [22] | ① | ● | ● | ○ |
We propose a new approach, built on two notions: tag operators and tags. A tag operator is a semantic operator, only a more basic one: it takes a single semantic condition and issues one model call about a single tuple, or about a single pair of tuples. A tag holds the value a model returns, as well as other information such as a confidence score, the model name, and a timestamp, which help track when each tag was produced and at what quality. A tag is an ordinary column the DBMS stores, indexes, and filters like any other, read and written through SQL. This granularity is what makes such reuse possible: an answer produced for a whole table at once can be reused only by a query asking the same question of the same data, whereas an answer stored in a tag serves any later tag operator and any future query that needs that tuple judged. None of the DB-based systems in Table 1 keeps a judgment past the query; at most it is kept within one. Reuse of arbitrary semantic conditions requires a data model designed for it. With the small set of tag operators that we define in Section 3, we are able to express the semantic operators commonly used in other semantic operator systems, by decomposing them into a composition of tag operators and ordinary relational operators (Section 3.2), but at a granularity at which the returned answers can be stored and reused.
Reuse also reaches beyond the identical question: through relationships between predicates, which an LLM judges from their meaning, the judgments a tuple already carries can accept it for a later predicate, eliminate it, or simplify its test; where they only make an answer more likely, they can still order the search of a query that stops early (Section 4).
To study the feasibility of this approach we built OCTOPUS, a prototype that extends a DBMS (PostgreSQL, but the design is not limited to it) with our tag model. Further, OCTOPUS aims to make writing the operator program optional: the user asks a question in natural language, and an LLM-based parser produces the plan of operators from it, though a plan can also be submitted directly. Queries that share semantic conditions then grow cheaper over the workload, since the tags written for earlier queries already answer part of new ones. On SemBench's [19] movie scenario, OCTOPUS judges 10 to fewer rows and pairs than four baselines, at competitive quality. The savings are the visible part of a larger shift. Every tag is a column no designer anticipated, added because a user asked, so the database's schema grows from its workload. Because each judgment is stored with its provenance, the same question receives the same answer across queries, and every answer can be audited or re-judged. A database used this way does not merely call a model: it accumulates what the model has established about its data, shared by every application that queries it.
This paper is thus organized as follows: Section 2 presents that data model, the tag, and the design of the semantic system built on a database that supports it. Section 3 argues that semantic operators are too coarse to be the unit of reuse, defines the tag operators as the appropriate unit, and shows how the existing operators translate onto them. Section 4 shows how the judgments a tuple already carries decide, simplify, or order the evaluation of later predicates. Section 5 reports a feasibility study with OCTOPUS, and Section 6 lays out the directions database research must pursue to make semantic operators first-class citizens of the database.
Tag provenance. A tag stores more than the value; it stores the value's provenance: the confidence score the executing model assigned to it, the name of that model, the execution timestamp, and, when semantic processing runs as a sequence of models of increasing capability (a cascade), the stage at which the value settled. A tag value can be wrong because of the model's accuracy or hallucination problems, and reusing it can turn a one-time error into a persistent one; the confidence score lets a later query compare the stored value against its own quality requirement and decide whether to trust it or evaluate the tuple again, so a low-confidence answer is not silently inherited. For an ordinary model execution, the score comes from the log probability the model reports for the token it emitted, which costs nothing beyond the call itself. The model name and the stage together record how much effort has already been spent on a tuple, so a query that is not satisfied with the stored value resumes at the next stage rather than the first. The timestamp records when that work happened, which lets the system find the answers that were produced before a model was replaced or the data was updated. In our design a tag value is an ordinary column, or a relation of its own when the judgment is about a pair, and the provenance is kept in a side table keyed by the tag and the tuple or pair, so the engine stores, indexes, and filters them like any other column and table.
Relation to other ways of storing model outputs. The ancestral idea is MauveDB's [10] model-based view, a relation whose content a model computes; a tag can be read as a semantic view that is partially materialized, filled tuple by tuple as queries demand, where MauveDB maintains its views as wholes. AIDB [14] materializes model outputs sparsely and caches them in an RDBMS, but its reuse is by exact invocation, without the provenance that lets a stored judgment be re-judged or answer a different question. Enrichment databases such as EnrichDB [12] compute derived attributes at query time and can materialize them, and semantic caches such as GPTCache [2] reuse a stored response when a new prompt is embedding-similar to an old one; tags sit between these, materialized on demand by the predicate the question itself introduces. None of these makes the per-judgment unit a persistent, queryable part of the database.
Tagging inside the database. A database that supports tagging suffices for a semantic processing system realized as a thin layer over the DBMS. A question posed in natural language, or as a program of semantic operators, is turned into a plan that separates the conditions SQL can express, which run first, from those that require a model's judgment. Each semantic condition routes through an operator that consults the relevant tag before any model is called: tuples the tag already covers are answered by a database read, only the open tuples reach a model, and every answer the model returns is written back to the tag. The tag operators that behave this way, are the subject of Section 3, and Section 5 describes OCTOPUS, the prototype we built.
3 TAG OPERATORS: THE RIGHT UNIT OF REUSE
To give semantic processing declarative form, systems such as LOTUS [25], Palimpzest [23], and iPDB [18] define semantic operators as primitives for expressing complex semantic queries: sem_filter, sem_map, sem_agg, sem_groupby, sem_join, and sem_topk (Table 2). Each carries a natural-language argument that a model judges: a predicate, an extraction target, or a comparison criterion.
Semantic operators are convenient to write, but they are too coarse to be the unit a system reuses. We use the sem_groupby operator as an example. Given a set of customer reviews about a product, a user asks for the five complaint topics over the reviews. Answering this complex query in LOTUS, for example, requires executing the sem_groupby operator over the table of reviews, which involves multiple intermediate steps: first identifies the complaint label of each review and then groups the labels into five complaint topics. However, if the system relies on one semantic operator sem_groupby, what it produces is a single answer for this query over the given data, and the reusability of that answer is limited to a query that asks exactly the same question over the same data. Suppose another query instead asks for ten example reviews complaining about “shipping issues”, one of the five complaint topics revealed by the previous query. It shares none of the work, although both need exactly the per-review judgment on the complaint label that sem_groupby already paid for at its first step.
The first advantage of decomposing a complex operator is therefore a large gain in workload reusability. Once sem_groupby is decomposed so that a map operator first extracts the complaint label of each review (Section 3.2), storing each label as a tag makes it reusable by any later query whose decomposition contains the same map — not only by another sem_groupby.
The second advantage is flexibility in where an optimization applies: any algorithm designed for the map operator can be embedded into the physical implementation of sem_groupby, cleanly separating the logical definition from the physical implementation. An optimization such as a cascade [1, 6], which is defined for a single per-tuple judgment, can be attached to the map inside sem_groupby without changing what sem_groupby means.
The principle the rest of the paper builds on follows: the unit of reuse and optimization is not the semantic operator but the single model judgment — one predicate applied to one tuple, or to one pair of tuples. Persist that unit, and reuse crosses operator boundaries: the same per-review label serves a groupby today and a filter tomorrow. Attach optimizations at that unit, and every operator built on it benefits at once. It is also the unit at which a stored judgment can settle a later predicate by itself, or narrow what the model must still judge. (Section 4).
3.1 The Tag Operators
A tag operator realizes exactly this unit. Most tag operators issue one or more calls to a model (an LLM for filter, map, and compare, or an embedding model for clustering) over a table T and persist the result as a tag, so that a later query demanding the same semantic condition can read the answer with ordinary SQL instead of calling the model again. Let P denote the natural-language argument passed to the model, e.g., a predicate such as is_vegan for a filter or an extraction target such as calories for a map. There are five tag operators. octo_filter and octo_map are identical to sem_filter and sem_map: each issues a single model call per tuple , so they are already the most fine-grained operators and need no further decomposition. octo_compare issues one model call per pair ; because no single tuple's row can hold an answer about two tuples, its tag is not a column but a relation, with one row per pair judged, keyed by . octo_clustering groups the tuples of T into k clusters using an embedding model rather than an LLM call, e.g., k-means over the values that octo_map extracted for predicate P. nest collapses a relation into fewer rows by grouping, or into a single row, as when a list of documents is summarized; it issues no model call and stores no tag, and is realized directly by ARRAY_AGG.
3.2 Translating Semantic Operators
Each semantic operator decomposes into a composition of tag operators and ordinary relational operators (sql_filter, sql_join, sql_groupby, sql_agg, sql_orderby, sql_limit). Table 2 lists the translation for each operator; the translation itself is fixed and adds no model call, so the result is correct given the decomposition and separability judgments that produced the plan, whose validation Section 6 lists as open. We work through one translation here; the rest follow a similar strategy.
Table 2: Semantic operators and their translation to tag operators.
| Sem Ops | Translation |
|---|---|
| sem_filter | octo_filter |
| sem_map | octo_map |
| sem_agg | attribute already a column: sql_agg ○ octo_filter attribute not yet a column: sql_agg ○ octo_map ○ octo_filter |
| sem_groupby | categories given: sql_agg ○ sql_groupby ○ octo_map categories not given: sql_agg ○ sql_groupby ○ octo_clustering ○ octo_map |
| sem_join | separable: sql_join ○ octo_map non-separable: sql_filter ○ octo_compare |
| sem_topk | separable: sql_limit ○ sql_orderby ○ octo_map non-separable: sql_limit ○ sql_orderby ○ sql_agg ○ octo_compare |
Consider again the five complaint topics from the beginning of this section: sem_groupby with categories not given, so that a label has to be produced for each review before any group exists, becomes sql_agg ○ sql_groupby ○ octo_clustering ○ octo_map: an octo_map extracts a complaint label per review and stores it as a tag, octo_clustering groups the labels into k clusters, and grouping and counting are ordinary SQL. Every intermediate judgment survives as a tag that any later query can read.
One judgment the translation turns on deserves note: a sem_join is separable when its condition can be decided by extracting a property from each tuple and comparing the two, and non-separable otherwise. iPDB applies the same decomposition, splitting a join that asks whether a CPU and a motherboard are compatible into an extraction of the socket type from each side and an ordinary match on it; in our terms an octo_map followed by a sql_join, so the cost falls from model calls to . When the join is non-separable, every pair is judged directly by octo_compare, and the quadratic cost is inherent. sem_topk splits the same way. This distinction is where the largest savings of Section 5.2 come from. Across every translation in Table 2, a model is called only inside a tag operator; every other step is work the database already does.
4 REUSING JUDGMENTS
A tag serves wider than a cache. Reusing a tag is not limited to the identical semantic condition: the tags of a tuple, one per judgment (Section 3), record what a model has established about it, and a later request can often be decided, or made cheaper, from them.
Tags as known facts. Consider a tuple on which tags have been evaluated. What is known about is the conjunction of existing tags , where is TRUE or FALSE for a binary tag such as tag_is_vegan, and a typed value for a map such as tag_map_calories; a tag not yet evaluated on holds NULL and contributes nothing. A new request asks whether satisfies a condition on a tag : that it equals a value, or falls in a set or range of values. Tags relate to one another through rules between their predicates, such as () (); we write for the rules known to the system. In the current prototype, the Parser's LLM derives them from common knowledge when a query arrives; a taxonomy, knowledge graph, or ontology could supply them instead (Section 6). A rule is derived once for a pair of predicates, not once for a tuple.
Reuse as entailment. A tuple is accepted with no model call if the rules and what is already known about , that is, , entail the condition ; eliminated if they entail its negation; and
Table 3: How a known fact of tuple decides a request .
| Rule | has | Outcome | Example ( / known fact) |
|---|---|---|---|
| (1) | accept | vegetarian / vegan=T (taxonomy); exact match, synonym | |
| (2) | eliminate | meat lover / vegan=T (complement, NOT) | |
| (3) | eliminate | vegan / vegetarian=F | |
| test residual | vegan / vegetarian=T | ||
| (4) | eliminate | contrapositive of (2) | |
| none entailed | open | judged by a model, ordered by |
open otherwise. Table 3 lists the four rules through which a single known fact of bears on . Take rule (3), where the fact is necessary for : vegan requires vegetarian, so a tuple with tag_is_vegetarian = FALSE is eliminated from a query for vegan food; a tuple with tag_is_vegetarian = TRUE is not decided, but its test simplifies, since vegan food is vegetarian food that excludes dairy, eggs, and honey, which we denote by the residual condition . Therefore, is equivalent on to , and only the residual needs testing, by a cheaper mechanism such as a keyword match over the ingredient list. If the residual has already been answered, the conjunction of the tags in can decide what none decides alone: the facts of a vegetarian tuple that also carries tag_hasDairy_or_hasEggs = FALSE and tag_hasHone = FALSE entail vegan. A map tag goes further: tag_map_calories = 200 answers any request that compares calories with a bound, by range containment, which SQL decides without rules or a model. Storing values therefore serves more requests than storing verdicts. The other rules read the same way, and exact match, synonym, complement, and taxonomy are their instances. Every rule compiles into the WHERE clause through a query rewriting approach [13], that selects the open tuples, so reuse adds no model call per tuple, and as long as the data and do not change, only grows, and with it the set of tuples decided without a model.
Probabilistic reuse. Entailment is the limit of a probabilistic view. Where and entail neither nor , still changes how likely is. Acceptance and elimination are the cases where is 1 and 0. A rule may hold only with probability . For example, P(\text{vegan} \mid \text{tag_hasChocolate=TRUE}) is not necessarily 0, but close to it, since few chocolate foods are vegan. Between 0 and 1 the probability can serve as a decision, accepting or eliminating once it is close enough to 1 or 0, which is safe only under a quality guarantee [16]; or as an order, which is always safe: for a query that stops early, with a LIMIT or EXISTS, any tuples that satisfy make a correct answer, so judging the open tuples in decreasing reaches the stopping condition with fewer model calls. The tag store can also estimate the rules themselves: tuples on which both and have been judged estimate , so it accumulates statistics on how predicates correlate, much as a database keeps histograms over its columns.
Related ideas. Deciding a request from known facts and rules aligns with two lines: semantic query optimization [3, 17] decides a predicate from declared constraints, and answering queries using views or semantic caching [4, 9, 13] splits a query into what is already stored and what remains. Both start from a schema and a rule set fixed at design time. The tag model lets them grow as queries arrive, a predicate the schema never carried becoming a column and the rules relating predicates being derived on demand,

Figure 1: OCTOPUS prototype on one query example.
at the price that our rules are beliefs that model judgments may violate, not constraints.
5 A FEASIBILITY STUDY: OCTOPUS
5.1 The OCTOPUS Prototype
Figure 1 depicts how a running example “find food products that are vegan, rated above 4” over Amazon product is handled in OCTOPUS. Parsing. An LLM-based agent Parser first receives the query and analyzes the predicates while reading the existing schema in the database. It separates the relational predicate rating > 4 from the semantic predicate is_vegan, and checks which stored tags are related to the latter, and how (Section 4). If no tag is reusable, the Parser creates the tag column (tag_is_vegan) in the relation, whose value is NULL for every tuple. It then outputs a logical plan with the relational filter and octo_filter, translated from sem_filter (Table 2). The current prototype accepts and eliminates tuples through exact match, synonym, complement, and taxonomy; simplifying the test and ordering the search are not yet implemented.
Parsing makes exactly one call to a state-of-the-art LLM per query, a fixed cost independent of the size of the database. The logical plan pushes down all relational conditions to ensure they execute first before any model judgment; since the natural-language interface rests on this one component, the Parser is constrained to emit a machine-validated typed schema. The logical plan then passes to the Executor, which decides how it executes, a question of cost rather than of meaning, and so needs no model of its own: it hands every relational operator to the DBMS and decides, for each tag operator, how the calls no tag settles are issued.
Execution. Execution proceeds in three steps, which Figure 1 continues. Read first: the database applies rating > 4 and prunes the tuples it excludes, and reads the value of tag_is_vegan for each tuple in one SQL query. If the user sets a threshold on the tag value's confidence score, the tag operator will select open tuples by: tag_is_vegan IS NULL OR conf_is_vegan < . The confidence score joins in from the tag provenance table of Section 2 and its threshold defaults to 0, trusting every stored value as it stands. A related tag enters the same query: when the Parser has found, say, that tag_is_vegetarian = FALSE eliminates a tuple for is_vegan (Section 4), that condition joins the WHERE clause, and such tuples never become open. Settle: the model judges the open tuples alone, one tuple per judgment (or one pair when the operator is octo_compare); the prototype issues the calls concurrently and batches several tuples into one prompt, and the Executor could add more optimization strategies such as model selection [31] and cascade execution [6, 7, 25]. Write back: each answer persists in its tag with its provenance (Section 2). Once the tuples the query needs carry a value (Section 5.2), the query is answered by the database alone, as rating > 4 AND tag_is_vegan = TRUE. The judgments this query paid for are data for whatever query comes next. Execution may be iterative rather than a single pass, stopping when its own conditions are met.
| Query | OCTOPUS | iPDB | ThalamusDB | PZ | LOTUS |
|---|---|---|---|---|---|
| Q1 (filter, LIMIT) | 20 | 10 | 20 | 15 | 1,865 |
| Q2 (filter, LIMIT) | 44 | 119 | 60 | 79 | 120 |
| Q3 (count) | 76 | 119 | 119 | 120 | 120 |
| Q4 (ratio) | 0 | 119 | 119 | 120 | 120 |
| Q5 (join, LIMIT) | 20 | 140 | 200 | 100 | 8,209 |
| Q6 (join, LIMIT) | 0 | 140 | 100 | 100 | 9,809 |
| Q7 (join) | 108 | 257 | 16,384 | 16,384 | 8,547 |
| Q8 (group by) | 0 | 1,864 | 238 | 120 | 120 |
| #rows/pairs judged | 268 | 2,768 | 17,240 | 17,038 | 28,910 |
| Mean quality | 0.82 | 0.87 | 0.83 | 0.79 | 0.79 |
Table 4: Cost in terms of numbers of rows judged by the model per query on SemBench movie (Q1-Q8).
5.2 Case Studies
Three case studies on SemBench's [19] movie scenario, chosen because its data is real (Rotten Tomatoes reviews) and its predicates recur across queries, examine OCTOPUS's and each baseline's capacity for reuse, intra-query and inter-query, plus the savings due to the database itself, the relational guard and the separable join. We compare OCTOPUS with iPDB [18], which extends DuckDB in-engine, ThalamusDB [15], which runs on DuckDB, LOTUS [25] and Palimpzest [23], which run their own engines. All systems run under one setup: gemini-2.5-flash, 20 concurrent calls, with 1,865 Reviews and 116 Movies with duplicates.
The measure on cost is independent of pricing and of batching: cost is counted by the number of rows (or pairs, for a join) the model judges. Batch size is set to one where a system exposes it; where a join packs several pairs into one prompt (iPDB, ThalamusDB), we count the pairs the prompt carries.
Case study 1: Reuse within a query. Within a query, the same input can reach the model more than once: some duplicates are in

Figure 2: The two groups of queries that share a tag: per query, the settled tuples read from the tag (teal) or judged by the model (orange).
the data (the benchmark’s Movies table lists 11 of its 105 films twice), and some are made by the plan, when a join fans one tuple out into many rows before a semantic filter reads it. OCTOPUS writes each model result to a tag on the base relation, one cell per tuple and predicate, which removes both, as the temporary per-query cache tables of iPDB and PLOP do. For “find family-friendly movies reviewed by a top critic” under a pull-up plan, Palimpzest, with no cache, passes 448 joined rows to the model; a cache keyed on the operator’s input, as in iPDB or through OCTOPUS’s per-movie tag, collapses them to 81, the number of distinct movies.
Case study 2: Reuse across queries. None of the systems we run keeps a judgment past the query: iPDB drops its table after PREDICT returns, Palimpzest keeps none, and LOTUS's optional cache is keyed on the rendered prompt, so a later query reuses an answer only if it renders the same text for the same row. Over Q1–Q8 (Table 4) OCTOPUS judges 268 rows against 2,768 for iPDB, 17,240 for ThalamusDB, 17,038 for Palimpzest and 28,910 for LOTUS, that is 10×, 64×, 64× and 108× fewer. The gap to iPDB is the reuse across queries alone, since both delegate the relational work to a DBMS and both reuse within a query; the gap to the other three adds the reuse within a query of case study 1 and the separable join of case study 3.
Figure 2 traces the queries that share a tag: within a group the first query pays for the tag, and later queries read what it holds, under the rules of Table 3. By rule (1), exact match: Q2 and Q3 fill tag_positive for taken_3 and Q5 fills it for ant_man, so Q4, Q8 and Q6 issue no model call, milliseconds of pure SQL. By rule (2), complement: Q8 and Q6 ask for opposite-sentiment reviews, answered with NOT on tag_positive. By rule (1) again, taxonomy: Q1's clearly positive is narrower than Q2's positive, so a tuple Q1 answered TRUE is settled for Q2, while a FALSE one stays open. Reuse is also partial: Q3 reuses the 44 tuples Q2's LIMIT settled, and Q7 starts from the 20 that Q5 settled.
Reuse has a price in quality: Q6 reads the tags Q5 left behind and scores 0.58, while Q7 judges the rest of the 128 reviews and reaches 0.74, so an inheriting query may repeat whatever earlier judgments got wrong. The confidence threshold (Section 5.1) and the strictness with which the Parser matches a new predicate to stored tags are the two knobs; Section 6 takes up both. SemBench runs each query once, in a fixed order, the least favorable case for reuse; in a real workload, where users repeat or rephrase queries [20, 28], the savings would only grow.
Case study 3: relational guard and separable join. These savings come with the database. Relational guard: a relational filter, such as the movie name in every query except Q1, is applied before any model is consulted, and a LIMIT stops evaluation early: on Q1, Q5 and Q6, OCTOPUS and iPDB stop once the SQL query meets it, Palimpzest pushes down a logical LIMIT, and LOTUS judges all 1,865. DISTINCT, HAVING and EXISTS settle early the same way, though SemBench does not exercise them. Separable join: Q5–Q7 ask for pairs of ant_man reviews with the same or opposite sentiment, a property of one review, so a tag operator judges each of the 128 once and a SQL self-join pairs the verdicts. On Q7, Palimpzest and ThalamusDB judge all 16,384 pairs, LOTUS 8,547, and iPDB 257 rows (it decomposes the join but judges each side separately), against 108 for OCTOPUS, at quality 0.74, the best of the five (0.24–0.73 for the others).
6 FUTURE DIRECTIONS
OCTOPUS is a prototype, but the position it argues points further: a database whose semantic schema is built by its users' questions, whose judgments are shared by every application that queries it, and whose answers stay consistent as the models beneath it change.
When to trust a reused answer. A stored judgment may itself be wrong (Section 2), so the Executor re-judges any value whose confidence falls below a threshold, which could give a query a quality guarantee. Reuse through a rule (Section 4) adds a second source of error: a rule is inferred rather than declared, and a wrong rule affects the queries that it judges. Whether a model-reported score can hold a guarantee, how much evidence a rule needs before it is trusted, and how to combine per-rule probabilities into an order over open tuples, are open.
The tag lifecycle. A tag is derived data, and the store that holds it needs maintenance, most of it offline: tags a workload rarely reads can be evicted to reclaim space; tags whose tuples have changed must be refreshed; and tags holding NULL can be filled while the system is idle. This is the view-maintenance problem [10] in a new setting: a tag is a partially materialized semantic view, and it needs maintaining not only when the data changes but when the model or the prompt that defines it does. Provenance records when a value was produced, but semantic staleness has no full treatment yet.
The parser as the trusted base. The Parser decides the order of the tag operators, the decomposition, and which stored tags a predicate may reuse. All three now rest on a frontier LLM guided only by a few instructions. Where one judgment falls short, the literature offers grounding in external knowledge, such as deriving the relationships between predicates from a taxonomy or knowledge graph rather than from the LLM alone [5], agreement across an ensemble read as a confidence [29], and abstention when that confidence is low [30]. How accurate the reuse judgment must be before permissive reuse is safe, and how that accuracy would be measured, are unstudied.
Into the engine. A cost-based optimizer that prices model calls next to I/O could reorder semantic and relational work rather than always pushing SQL first, and write-back during reads raises transactional questions the middleware currently sidesteps.
REFERENCES
[1] Pranjal Aggarwal, Aman Madaan, Ankit Anand, Srividya Pranavi Potharaju, Swaroop Mishra, Pei Zhou, Aditya Gupta, Dheeraj Rajagopal, Karthik Kappaganthu, Yiming Yang, et al. 2024. Automix: Automatically mixing language models. Advances in Neural Information Processing Systems 37 (2024), 131000–131034.
[2] Fu Bang. 2023. Gptcache: An open-source semantic cache for llm applications enabling faster answers and cost savings. In Proceedings of the 3rd Workshop for Natural Language Processing Open Source Software (NLP-OSS 2023). 212–218.
[3] Upen S. Chakravarthy, John Grant, and Jack Minker. 1990. Logic-Based Approach to Semantic Query Optimization. ACM Transactions on Database Systems 15, 2 (1990), 162–207.
[4] Surajit Chaudhuri, Ravi Krishnamurthy, Spyros Potamianos, and Kyuseok Shim. 1995. Optimizing queries with materialized views. In Proceedings of the Eleventh International Conference on Data Engineering. IEEE, 190–200.
[5] Jiaoyan Chen, Yuan He, Yuxia Geng, Ernesto Jiménez-Ruiz, Hang Dong, and Ian Horrocks. 2023. Contextual semantic embeddings for ontology subsumption prediction. World Wide Web 26, 5 (2023), 2569–2591.
[6] Lingjiao Chen, Matei Zaharia, and James Zou. 2023. Frugalgpt: How to use large language models while reducing cost and improving performance. arXiv preprint arXiv:2305.05176 (2023).
[7] Ashwin Colaco, Sharad Mehrotra, Michael De Lucia, Kevin Hamlen, Murat Kantarcioglu, Latifur Khan, Ananthram Swami, Bhavani Thuraisingham, and Unnat Jain. 2026. Unifying Stacking and Cascading for Efficient Ensemble Inference. In International Conference on Machine Learning (ICML).
[8] Benoit Dageville, Thierry Cruanes, Marcin Zukowski, Vadim Antonov, Artin Avanes, Jon Bock, Jonathan Claybaugh, Daniel Engovatov, Martin Hentschel, Jiansheng Huang, Allison W. Lee, Ashish Motivala, Abdul Q. Munir, Steven Pelley, Peter Povinec, Greg Rahn, Spyridon Triantafyllis, and Philipp Unterbrunner. 2016. The Snowflake Elastic Data Warehouse. In Proceedings of the 2016 International Conference on Management of Data (SIGMOD). 215–226.
[9] Shaul Dar, Michael J Franklin, Bjorn T Jonsson, Divesh Srivastava, Michael Tan, et al. 1996. Semantic data caching and replacement. In VLDB, Vol. 96. 330–341.
[10] Amol Deshpande and Samuel Madden. 2006. MauveDB: supporting model-based user views in database systems. In Proceedings of the 2006 ACM SIGMOD International Conference on Management of Data. 73–84.
[11] Anas Dorbani, Sunny Yasser, Jimmy Lin, and Amine Mhedhbi. 2025. Beyond Quacking: Deep Integration of Language Models and RAG into DuckDB. Proceedings of the VLDB Endowment 18, 12 (2025), 5415–5418.
[12] Dhrubajyoti Ghosh, Peeyush Gupta, Sharad Mehrotra, Roberto Yus, and Yasser Altowim. 2022. JENNER: just-in-time enrichment in query processing. Proceedings of the VLDB Endowment 15, 11 (2022).
[13] Alon Y Halevy. 2001. Answering queries using views: A survey. The VLDB Journal 10, 4 (2001), 270–294.
[14] Tengjun Jin, Akash Mittal, Chenghao Mo, Jiahao Fang, Chengsong Zhang, Timothy Dai, and Daniel Kang. 2024. AIDB: a sparsely materialized database for queries using machine learning. In Proceedings of the Eighth Workshop on Data Management for End-to-End Machine Learning (DEEM@SIGMOD). 23–28.
[15] Saehan Jo and Immanuel Trummer. 2024. Thalamusdb: Approximate query processing on multi-modal data. Proceedings of the ACM on Management of Data 2, 3 (2024), 1–26.
[16] Daniel Kang, Edward Gan, Peter Bailis, Tatsunori Hashimoto, and Matei Zaharia. 2020. Approximate Selection with Guarantees using Proxies. Proceedings of the VLDB Endowment 13, 11 (2020), 1990–2003.
[17] Jonathan J. King. 1981. QUIST: A System for Semantic Query Optimization in Relational Databases. In Proceedings of the 7th International Conference on Very Large Data Bases (VLDB). 510–517.
[18] Udesh Kumarasinghe, Tyler Liu, Ahmed Mahmood, Chunwei Liu, and Walid G. Aref. 2026. iPDB: SQL with ML and LLM Predicates. Proceedings of the VLDB Endowment 19, 12 (2026), 4782–4785.
[19] Jiale Lao, Andreas Zimmerer, Olga Ovcharenko, Tianji Cong, Matthew Russo, Gerardo Vitagliano, Michael Cochez, Fatma Özcan, Gautam Gupta, Thibaud Hottelier, H. V. Jagadish, Kris Kissel, Sebastian Schelter, Andreas Kipf, and Immanuel Trummer. 2025. SemBench: A Benchmark for Semantic Query Processing Engines. arXiv:2511.01716 [cs.DB] https://arxiv.org/abs/2511.01716
[20] Keming Li, Nada Lahjouji, Ashwin Gerard Colaco, Shiyuan Zhou, Pratyoy Das, Guangxue Zhang, Sahil Makhijani, Vishal Chakraborty, Sarvesh Pandey, and Sharad Mehrotra. 2026. WorkLoadWeaver: Realistic Synthetic Query Workloads for Adaptive Database Systems. In Proceedings of the Workshop on Synthetic Data Generation and Management for Building AI Systems (SynthAI '26). Association for Computing Machinery, New York, NY, USA, 18–26. https://doi.org/10.1145/3814574.3816743
[21] Yin Lin, Tianjing Zeng, Zhongjun Ding, Rong Zhu, Bolin Ding, HV Jagadish, and Jingren Zhou. 2026. SEMA-SQL: Beyond Traditional Relational Querying with Large Language Models. arXiv preprint arXiv:2604.23477 (2026).
[22] Pawel Liskowski, Benjamin Han, Paritosh Aggarwal, Bowei Chen, Boxin Jiang, Nitish Jindal, Zihan Li, Aaron Lin, Kyle Schmaus, Jay Tayade, et al. 2026. Cortex aisql: A production sql engine for unstructured data. In Companion of the
International Conference on Management of Data. 400–412.
[23] Chunwei Liu, Matthew Russo, Michael Cafarella, Lei Cao, Peter Baile Chen, Zui Chen, Michael Franklin, Tim Kraska, Samuel Madden, Rana Shahout, et al. 2025. Palimpzest: Optimizing ai-powered analytics with declarative query processing. In Proceedings of the Conference on Innovative Database Research (CIDR). 2.
[24] Qiuyang Mang, Yufan Xiang, Hangrui Zhou, Runyuan He, Jiaxiang Yu, Hanchen Li, Aditya Parameswaran, and Alvin Cheung. 2026. PLOP: Cost-Based Placement of Semantic Operators in Hybrid Query Plans. arXiv preprint arXiv:2604.09944 (2026).
[25] Liana Patel, Siddharth Jha, Melissa Pan, Harshit Gupta, Parth Asawa, Carlos Guestrin, and Matei Zaharia. 2024. Semantic operators: a declarative model for rich, ai-based data processing. arXiv preprint arXiv:2407.11418 (2024).
[26] Kangkang Qi, Dongyang Xie, Wenbo Li, Hao Zhang, Yuanyuan Zhu, Jeffrey Xu Yu, and Kangfei Zhao. 2026. Sema: A High-performance System for LLM-based Semantic Query Processing. arXiv preprint arXiv:2603.11622 (2026).
[27] Mark Raasveldt and Hannes Mühleisen. 2019. Duckdb: an embeddable analytical database. In Proceedings of the 2019 international conference on management of data. 1981–1984.
[28] Chandan K. Reddy, Lluís Márquez, Fran Valero, Nikhil Rao, Hugo Zaragoza, Sambaran Bandyopadhyay, Arnab Biswas, Anlu Xing, and Karthik Subbian. 2022. Shopping Queries Dataset: A Large-Scale ESCI Benchmark for Improving Product Search. (2022). arXiv:2206.06588
[29] Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc Le, Ed Chi, Sharan Narang, Aakanksha Chowdhery, and Denny Zhou. 2022. Self-consistency improves chain of thought reasoning in language models. arXiv preprint arXiv:2203.11171 (2022).
[30] Bingbing Wen, Jihan Yao, Shangbin Feng, Chenjun Xu, Yulia Tsvetkov, Bill Howe, and Lucy Lu Wang. 2025. Know your limits: A survey of abstention in large language models. Transactions of the Association for Computational Linguistics 13 (2025), 529–556.
[31] Guangxue Zhang, Yiming Lin, and Sharad Mehrotra. 2026. OctoSelector: Efficient and Effective Batch-Aware Model Selection for Large Language Models. Proceedings of the ACM on Management of Data 4, 3 (SIGMOD) (2026), 1–26.