Profile Your Database

Measure the performance of your Firebase Realtime Database with the database profiler tool, built into the Firebase CLI. The profiler tool logs all the activity in your database over a given period of time, then generates a detailed report. Use the detailed report to troubleshoot issues with your database performance, spot problem areas, and reduce unindexed queries.

Build a profile

  1. Before you start profiling your Firebase Realtime Database, make sure you're using the latest version of the Firebase CLI and that you've initialized it for the database and project you want to profile.

  2. Start profiling your database with the following command:

    firebase database:profile
    The profiler displays a status message as it records operations from your database and builds the profile.

  3. Press Enter to complete the profile and display the results.

Interpret your results

The profiler tool aggregates the data it's collected about your database's operations and displays the results in three primary categories: speed, bandwidth, and unindexed queries.

Speed

The Speed Report measures the server's response time (in milliseconds) for each operation type. However, the speed measured in the Speed Report might not actually reflect the speed end-users experience. Different factors, including network conditions, can add latency on the client side.

The Speed Report includes the following properties:

  • Path: The path in your database where the operations occurred. If there are more than 25 child nodes, the profiler tool collapses these into a parent path and adds a $wildcard marker. You might see your database's root directory in the report, represented by a forward slash /.
  • Count: The number of operations that occurred at the given path.
  • Average: The average time it takes the server to process a particular operation type at that path.
  • Permission Denied: The number of operations at the given path that were blocked by Firebase Database Rules on your database.
Speed Report by Operation Type
Read Speed The server response time for client requests to read data from the database.
Write Speed The server response time for client requests to write data to the database.
Broadcast Speed

The amount of time the server takes to distribute data to clients listening to the given path for realtime updates.

The Count property in the Broadcast Speed Report aggregates the number of broadcasts that happened, not the number of clients that received the information. For example, if 10 clients were listening at a given path, and the server broadcast an update to all 10 clients, the broadcast count only reflects 1 broadcast, even though 10 clients received the data.

The Permission Denied property isn't included in the Broadcast Speed report.

Bandwidth

The Bandwidth Report provides insight on how much data your database consumes across incoming and outgoing operations. You shouldn't use the Bandwidth Report to estimate billing, however, because it doesn't include bandwidth used for other operations, like profiling your database. The Bandwidth Report roughly estimates the payload size of the data consumed by read, write, and broadcast operations to and from your database. It's a tool that measures performance, not one that forecasts billing.

The Bandwidth Report includes the following properties:

  • Path: The path in your database where the operations occurred. If there are more than 25 child nodes, the profiler tool collapses these into a parent path.

  • Total: The total outgoing or incoming bytes used across all operations at the given path.

  • Count: The number of operations that occurred at the given path.
  • Average: The average number of downloaded or uploaded bytes across operations at the given path (bytes/write or bytes/read).
Bandwidth Report
Downloaded Bytes Data consumed through read and broadcast operations sent out via the client SDKs and REST API.
Uploaded Bytes Data consumed through write requests coming into the database server. Deletes show up as writes with 0 bytes under incoming.

Unindexed Queries

Unindexed queries can be expensive, because clients download all of the data at a location and then perform queries on it. This uses up more bandwidth than necessary. Resolve as many unindexed queries as you can to optimize your database's performance.

The Unindexed Queries report displays the following properties:

  • Path: The path in your database where the unindexed queries occurred.
  • Index: The rule you should add to resolve the unindexed queries. Learn more about indexing in Index your data.
  • Count: The number of unindexed queries that occurred at the given path.

Advanced profiling

To see all the operations your database is handling, use the --raw flag when you profile your database, as follows:

firebase database:profile --raw

The raw output also includes client information for each operation, such as userAgent strings and IP addresses. Learn more about the different operations profiled in your Firebase Realtime Database in Firebase Realtime Database Operation Types.

Send feedback about...

Need help? Visit our support page.