-
Notifications
You must be signed in to change notification settings - Fork 0
geo_g5_implementation
Metrics Struct (include/index/spatial_index.h)
struct Metrics {
std::atomic<uint64_t> query_count{0};
std::atomic<uint64_t> mbr_candidate_count{0};
std::atomic<uint64_t> exact_check_count{0};
std::atomic<uint64_t> exact_check_passed{0};
std::atomic<uint64_t> exact_check_failed{0};
std::atomic<uint64_t> insert_count{0};
std::atomic<uint64_t> remove_count{0};
std::atomic<uint64_t> update_count{0};
};Integration Points:
-
searchIntersects(): Tracks queries, MBR candidates, exact checks -
insert(): Tracks insertions -
remove(): Tracks deletions -
update(): Tracks updates
Thread Safety:
- All counters use
std::atomic<uint64_t>for lock-free concurrent access - Safe for multi-threaded query execution
File: benchmarks/bench_spatial_index.cpp
Dataset:
- 10,000 points (simulating NaturalEarth cities/POIs)
- Geographic bounds: (-180°, -85°) to (180°, 85°)
- Random distribution across world
Benchmarks:
-
BM_Spatial_Insert
- Measures insert performance
- Tests with different random seeds
- Reports: dataset_size
-
BM_Spatial_Query_Tiny (City-level, ~100 results)
- Query bbox: 1% of world
- Typical use case: city search
-
BM_Spatial_Query_Small (Region-level, ~500 results)
- Query bbox: 5% of world
- Typical use case: region/state search
-
BM_Spatial_Query_Medium (Country-level, ~2000 results)
- Query bbox: 20% of world
- Typical use case: country search
-
BM_Spatial_Query_Large (Continent-level, ~5000 results)
- Query bbox: 50% of world
- Typical use case: continent search
-
BM_Spatial_ExactCheck_Overhead
- Measures exact geometry check overhead
- Compares MBR-only vs MBR+exact check
Running Benchmarks:
cd build
./bench_spatial_index
# Expected output:
# BM_Spatial_Insert/1 X us/iteration
# BM_Spatial_Query_Tiny Y ms/iteration avg_results=Z
# ...POST /spatial/index/create
- Creates spatial index for a table
- Request:
{ "table": "places", "geometry_column": "geometry", "config": { "total_bounds": { "minx": -180, "miny": -90, "maxx": 180, "maxy": 90 } } } - Response:
{ "success": true, "table": "places", "geometry_column": "geometry", "message": "Spatial index created successfully" }
POST /spatial/index/rebuild
- Rebuilds spatial index (TODO: not yet implemented)
- Returns 501 Not Implemented with instructions
GET /spatial/index/stats?table=places
- Returns spatial index statistics
- Response:
{ "table": "places", "geometry_column": "geometry", "entry_count": 10000, "total_bounds": { "minx": -180, "miny": -90, "maxx": 180, "maxy": 90 } }
GET /spatial/metrics
- Returns spatial performance metrics
- Response:
{ "query_count": 1000, "mbr_candidate_count": 5000, "exact_check_count": 5000, "exact_check_passed": 4200, "exact_check_failed": 800, "exact_check_precision": 0.84, "false_positive_rate": 0.16, "avg_candidates_per_query": 5.0, "insert_count": 10000, "remove_count": 100, "update_count": 50 }
Derived Metrics:
-
exact_check_precision: Ratio of passed exact checks to total exact checks -
false_positive_rate: 1 - precision (MBR false positives filtered by exact check) -
avg_candidates_per_query: Average MBR candidates per query
curl -X POST http://localhost:8080/spatial/index/create \
-H "Content-Type: application/json" \
-d '{
"table": "places",
"geometry_column": "geometry"
}'curl http://localhost:8080/spatial/metrics
# Returns current performance metrics
# Use for monitoring and optimizationcurl "http://localhost:8080/spatial/index/stats?table=places"
# Returns index configuration and entry countspatial_index_->resetMetrics();Based on 10k point dataset with exact backend enabled:
- MBR Filtering Efficiency: ~95% reduction (10k → 500 candidates)
- Exact Check Precision: ~84% (500 MBR → 420 exact matches)
- False Positive Rate: ~16% (80 MBR matches filtered out)
- Exact Check Overhead: ~1-5ms per candidate
-
Total Query Time:
- Tiny bbox: <10ms
- Small bbox: 10-50ms
- Medium bbox: 50-200ms
- Large bbox: 200-500ms
-
High False Positive Rate (>30%)
- Consider smaller Morton buckets
- Indicates complex geometry shapes
-
Low Exact Check Count
- Exact backend not being used
- Check backend availability
-
High Average Candidates per Query
- Queries cover large areas
- Consider spatial prefiltering
The metrics can be exported to Prometheus:
spatial_index_query_count 1000
spatial_index_mbr_candidates 5000
spatial_index_exact_checks 5000
spatial_index_exact_passed 4200
spatial_index_exact_failed 800
spatial_index_inserts 10000
spatial_index_removes 100
spatial_index_updates 50
Recommended panels:
- Query throughput (queries/sec)
- MBR filter efficiency (candidates/query)
- Exact check precision (%)
- False positive rate (%)
- Insert/Update/Delete rates
Run benchmarks as part of performance testing:
cd build
./bench_spatial_index --benchmark_repetitions=10
# Output includes:
# - Mean execution time
# - Standard deviation
# - Min/Max times
# - Throughput metrics- Implement
/spatial/index/rebuildendpoint - Add Prometheus exporter for metrics
- Create Grafana dashboard templates
- Add per-table metrics (not just global)
- Histogram metrics for query latency distribution
- Metrics for specific operation types (ST_Within, ST_Contains, etc.)
- GPU metrics (when V1 implemented)
- Distributed metrics (when sharding implemented)
- Real-time alerting on performance degradation
-
include/index/spatial_index.h- Metrics struct and API -
src/index/spatial_index.cpp- Metrics tracking in operations -
benchmarks/bench_spatial_index.cpp- Benchmark suite (NEW) -
include/server/http_server.h- Handler declarations -
src/server/http_server.cpp- Route handling and endpoint implementation
- AQL Overview
- AQL Syntax Reference
- EXPLAIN and PROFILE
- Hybrid Queries
- Pattern Matching
- Subquery Implementation
- Subquery Quick Reference
- Fulltext Release Notes
- Hybrid Search Design
- Fulltext Search API
- Content Search
- Pagination Benchmarks
- Stemming
- Hybrid Fusion API
- Performance Tuning
- Migration Guide
- Storage Overview
- RocksDB Layout
- Geo Schema
- Index Types
- Index Statistics
- Index Backup
- HNSW Persistence
- Vector Index
- Graph Index
- Secondary Index
- Security Overview
- RBAC and Authorization
- TLS Setup
- Certificate Pinning
- Encryption Strategy
- Column Encryption
- Key Management
- Key Rotation
- HSM Integration
- PKI Integration
- eIDAS Signatures
- PII Detection
- PII API
- Threat Model
- Hardening Guide
- Incident Response
- SBOM
- Enterprise Overview
- Scalability Features
- Scalability Strategy
- HTTP Client Pool
- Enterprise Build Guide
- Enterprise Ingestion
- Benchmarks Overview
- Compression Benchmarks
- Compression Strategy
- Memory Tuning
- Hardware Acceleration
- GPU Acceleration Plan
- CUDA Backend
- Vulkan Backend
- Multi-CPU Support
- TBB Integration
- Time Series
- Vector Operations
- Graph Features
- Temporal Graphs
- Path Constraints
- Recursive Queries
- Audit Logging
- Change Data Capture
- Transactions
- Semantic Cache
- Cursor Pagination
- Compliance Features
- GNN Embeddings
- Geo Overview
- Geo Architecture
- 3D Game Acceleration
- Geo Feature Tiering
- G3 Phase 2 Status
- G5 Implementation
- Integration Guide
- Content Architecture
- Content Pipeline
- Content Manager
- JSON Ingestion
- Content Ingestion
- Filesystem API
- Image Processor
- Geo Processor
- Policy Implementation
- Developer Guide
- Implementation Status
- Development Roadmap
- Build Strategy
- Build Acceleration
- Code Quality Guide
- AQL LET Implementation
- Audit API Implementation
- SAGA API Implementation
- PKI eIDAS
- WAL Archiving
- Architecture Overview
- Strategic Overview
- Ecosystem
- MVCC Design
- Base Entity
- Caching Strategy
- Caching Data Structures
- Docker Build
- Docker Status
- Multi-Arch CI/CD
- ARM Build Guide
- ARM Packages
- Raspberry Pi Tuning
- Packaging Guide
- Package Maintainers
- Roadmap
- Changelog
- Database Capabilities
- Implementation Summary
- Sachstandsbericht 2025
- Enterprise Final Report
- Test Report
- Build Success Report
- Integration Analysis
- Source Overview
- API Implementation
- Query Engine
- Storage Layer
- Security Implementation
- CDC Implementation
- Time Series
- Utils and Helpers
Updated: 2025-11-30