Common queries
As you connect to the database, you will be able to retrieve data via SQL queries. This section provides sample SQL queries to help you start working with the Private Telematics Lakehouse. These examples demonstrate how to access and analyze data from the Bronze layer, which contains raw business and telematic data with minimal transformation.
Please note: Due to the database containing a huge amount of information, please make sure to make test queries based on a limited number of values retrieved.
Basic queries
Retrieve basic object information
This query returns information about objects (vehicles/assets) in your system:
SELECT
o.object_id,
o.object_label,
o.model,
d.device_imei,
g.group_label
FROM
raw_business_data.objects o
LEFT JOIN raw_business_data.devices d ON o.device_id = d.device_id
LEFT JOIN raw_business_data.groups g ON o.group_id = g.group_id
WHERE
o.is_deleted = false
ORDER BY
o.object_label;Get latest device locations
Retrieve the most recent location data for all your devices:
Joining business and telematic data
Vehicle activity report
This query generates a daily activity summary by joining business and telematic data:
Driver assignments and location history
Track which employees were assigned to which vehicles and their location history:
Analyzing sensor data
Fuel level tracking
This query shows how to analyze fuel sensor data:
Geospatial analysis
Vehicles in geozones
Identify which vehicles entered specific geozones:
Performance optimization tips
When working with the Cloud Data Warehouse, consider these optimization techniques:
Use time-based filtering: Always include a time filter on the
device_timeorrecord_added_atcolumns to limit the data scanned. Good practice:
Avoid this (scans entire table)
Leverage indexes: The database has indexes on
(device_id, device_time)pairs. Structure your queries to use these indexes when possible.Use joins selectively: Join tables only when necessary and try to filter data before joining large tables.
Scale integer conversion: Remember that coordinate data is stored as scaled integers. Convert only in the final SELECT, not in WHERE clauses.
Limit result sets: Always use LIMIT for exploratory queries to avoid returning millions of rows.
Utilize hierarchical relationships: Structure complex queries following the entity hierarchy (dealer → client → user/device → object) for more efficient joins and filtering.
Manage connections properly: Close database connections when they're not in use, especially in BI tools or scheduled scripts, to avoid resource locking or timeout issues.
Next steps
These examples provide a starting point for working with your data. As you become more familiar with the schema, you can develop more complex queries to meet your specific business needs.
Last updated
Was this helpful?