Indexes
Indexes, importantly, the correct ones are essential to get the most of the database and the query. Non-existent or poorly created indexes can adversely impact the performance of your queries
Basic indexing
Run the following query:
for flight IN flights filter flight.TailNum == "N505JB" return flight
If you profile the query you should see something like this:
You see that the collection is being enumerated in id #2 (Scan Full) and importantly, no indexes are being used
Let's go and create an index next and see what difference it makes
Navigate to the collection you need, in the case the flights collection
Next click (+) to add a new index
Then specify the index details and create it in the background
- (1) Type: Persistent index
- (2) Fields: TailNum
- (3) Name: TailNumIndex (if you dont specify a name arangodb will generate one for you)
- (4) Click Create , Leaving the rest of the fields as defaults
You should be able to see the status of the index once created:
Now go back to the query edit and rerun the query profiler and query.
Compare the plan and execution times
You can clearly see that there wasn't any full scan done and the execution time is significantly better
Anything unclear or buggy in this tutorial? Provide Feedback