You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add HTTP/HTTPS support for remote SQLite databases
Implements seamless support for querying remote SQLite databases over HTTP/HTTPS
using DuckDB's CachingFileSystem infrastructure. This enables direct SQL queries
against SQLite files hosted on web servers without downloading the entire database.
Key Features:
- Custom SQLite VFS (Virtual File System) that integrates with DuckDB's external file cache
- Adaptive read-ahead optimization (1MB-128MB) for efficient remote file access
- Per-ClientContext VFS registration for thread-safe concurrent access
- Automatic VFS lifecycle management tied to ClientContext lifetime
- Full support for sqlite_scan, sqlite_attach, and SQLite storage engine operations
Implementation Details:
- SQLiteDuckDBCacheVFS: Custom VFS that delegates file I/O to DuckDB's CachingFileSystem
- DuckDBCachedFile: Wrapper around DuckDB's CachingFileHandle with adaptive read-ahead
- Uses DuckDB's FileSystem::IsRemoteFile() for automatic HTTP/HTTPS detection
- Leverages DuckDB's httpfs extension for HTTP client functionality
- Modified SQLiteDB::Open to automatically register VFS for remote files
- Added comprehensive test suite covering VFS registration, basic scans, joins, CTEs, etc.
Performance Optimizations:
- Adaptive read-ahead reduces HTTP round trips for sequential scans
- DuckDB's CachingFileSystem provides intelligent block caching and prefetching
- Read-only access mode for remote files ensures optimal caching behavior
This change enables use cases like:
- Querying SQLite databases hosted on CDNs or web servers
- Analyzing remote SQLite files without local storage requirements
- Building data pipelines that directly access HTTP-hosted SQLite databases
Example usage:
```sql
-- Direct scan
SELECT * FROM sqlite_scan('https://github.com/lerocha/chinook-database/raw/master/ChinookDatabase/DataSources/Chinook_Sqlite.sqlite', 'Artist');
-- Attach remote database
ATTACH 'https://github.com/lerocha/chinook-database/raw/master/ChinookDatabase/DataSources/Chinook_Sqlite.sqlite' AS http_db (TYPE sqlite);
-- Query attached database
SELECT COUNT(*) FROM http_db.Track;
```
0 commit comments