Amit Khare
02/16/2026, 4:19 PMTony Wasson
02/16/2026, 10:34 PMAmit Khare
02/17/2026, 1:34 PMTony Wasson
02/18/2026, 8:44 PMRocky
02/18/2026, 8:45 PMentity_id, attribute_name, and attribute_value.
* Best Model for EAV: If you must use EAV for point lookups (retrieving all attributes for a single ID), you should use the Primary Key model. This allows for high-concurrency, low-latency lookups.
* The Problem: For analytical queries (e.g., "What is the average price of all blue items?"), an EAV model requires complex self-joins, CASE WHEN statements, or PIVOT operations. These operations are computationally expensive and cannot fully leverage StarRocks' columnar pruning.
2. EAV vs. Wide Table Performance
In almost all OLAP (Online Analytical Processing) scenarios, a Wide Table will be significantly faster than an EAV model for the following reasons:
Feature | Wide Table (Recommended) | EAV Model
Storage | Columnar (highly compressed). | Row-like (one attribute per row, redundant IDs).
Data Pruning | Only reads the specific columns needed for a query. | Must scan all rows to filter for specific attributes.
Vectorization | High efficiency with SIMD instructions. | Lower efficiency due to row-based filtering/pivoting.
Query Logic | Simple SQL (e.g., SELECT price FROM table). | Complex SQL (e.g., SELECT value FROM table WHERE attr='price').
Speed | Fastest for aggregations and filtering. | Slower for bulk analytics; better only for sparse schema flexibility.
3. The StarRocks Alternative: Flat JSON
If the reason you are considering EAV is schema flexibility (i.e., you have hundreds of sparse attributes that change often), StarRocks offers a modern alternative that outperforms traditional EAV: The JSON Data Type with Flat JSON.
* How it works: You can store your sparse attributes in a single JSON column.
* Automatic Flattening: Starting from version 3.3.0 (and enabled by default in v4.0), StarRocks features Flat JSON. It automatically detects frequently queried keys inside your JSON and materializes them into internal standard columns.
* The Result: You get the flexibility of EAV (adding new attributes without a schema change) with the performance of a wide table (direct columnar access to those attributes).
Summary Advice
* If performance is your priority: Use a Wide Table. StarRocks handles hundreds or even thousands of columns very efficiently.
* If you have highly sparse data: Use a JSON column with Flat JSON enabled. This provides the best balance between flexibility and performance.
* Only use EAV if: Your application requires an extremely dynamic, user-defined attribute system and you primarily perform point lookups rather than large-scale data analysis.
References
• using_starrocks/Flat_json.md
• best_practices/query_tuning/schema_tuning.md
• knowledge/usage/best-practice.md
• sql-reference/data-types/semi_structured/JSON.mdAmit Khare
02/18/2026, 9:27 PMAmit Khare
02/18/2026, 9:27 PMRocky
02/18/2026, 9:28 PMARRAY types) will be much faster.
3. Sorting and Indexing Limitations
* Data Sorting: In StarRocks, performance is heavily tied to the ORDER BY (sorting) keys, which allow for efficient data pruning. You cannot use a JSON column (or a field within it via Flat JSON) as a sorting key. In a wide table, you can pick your most important fields as the DUPLICATE/PRIMARY KEY to drastically speed up filtering.
* Secondary Indexes: You cannot currently build Bitmap Indexes or Bloom Filter Indexes directly on the sub-fields within a Flat JSON column. In a wide table, you have full control to add these indexes to any specific column.
4. Query & Join Complexity
* Joining/Grouping: JSON columns (even with Flat JSON) have restrictions in JOIN, GROUP BY, and ORDER BY clauses. While the Cost-Based Optimizer (CBO) can sometimes rewrite these if you enable cbo_json_v2_rewrite, a wide table with standard types is supported natively across all SQL operations without needing specific session variables or rewrites.
* Schema Consistency: Flat JSON relies on a "Sparsity Factor." If a field is only present in 10% of your rows, Flat JSON might not extract it into a sub-column, leaving it in the slow JSON blob. In a wide table, that field is a column regardless, ensuring consistent performance.
5. Loading Speed
* Extra Processing: Enabling Flat JSON increases the computation required during the data load process. The more fields StarRocks has to extract and infer, the longer the INSERT or ROUTINE LOAD will take compared to loading into a pre-defined wide table.
Comparison Summary
Feature | Flat JSON | Wide Table
Schema | Flexible (Schema-on-read feel) | Rigid (Requires ALTER TABLE)
Performance | High (Good for ad-hoc) | Maximum (Best for fixed reports)
Arrays | Not materialized | Fully supported via ARRAY type
Pruning | Limited (No sorting keys) | Excellent (Uses ORDER BY keys)
Indexes | Not supported on sub-fields | Full support (Bitmap, Bloom Filter)
Rocky's Recommendation:
Use Flat JSON when your schema changes frequently or you have "long-tail" fields that you don't want to manage manually. Use a Wide Table for your most critical, high-concurrency queries where you need every millisecond of performance and need to sort or index the data.
Let me know if you want to see how to configure the Flat JSON sparsity settings or how to transition from one to the other!Rocky
02/18/2026, 9:28 PM