API Maker
The backend engine for the AI era
Automatic indexesEpisode 31 9:08 11 chapters November 2026
Indexes that find themselves: recorded, decided, written down with a reason, and created in every environment. Turn on the automatic mode of Index Maker, watch its first decision with a reason for every query, then carry its decisions to every environment with the am_index_maker migration script and the index system APIs.
In the playlists The complete course Performance
Here are indexes that find themselves. They are recorded, decided, written down with a reason, and created in every environment. In this video, we look at the automatic mode of Index Maker, and its migration script.
Indexes are usually a pain. Nobody has time to watch query plans. An index is added by hand on production, the night it was slow. And it is missing on staging, on the laptop of the next developer, and in the next region. With API Maker, the automatic mode records the real queries, and decides by itself. It writes a reason for every query. And every index is a line in one migration script, which every environment runs.
In this video: the automatic mode and its settings, its first decision, how it decides, the migration script am_index_maker, index names on every database, and the system APIs for indexes.
Open Database, then Index Maker. On the left, Automatic indexes is off. It records, decides, and indexes. Its settings are kept on the account, so they travel with the project in Git. A scan records thirty minutes of queries every six hours. For this video, it records one minute. A query without an index gets one when its table has at least ten thousand rows, and it is slower than a hundred milliseconds, or called at least fifty times.
An index has three fields at most, and a table has twelve indexes at most. They are created on this server too, not only in the script. The last three automatic periods are kept, and you can leave tables out. Click Save settings. Now turn the switch on. The first scan starts within a minute, or right now, with Scan now. An automatic scanning period records the database queries of your APIs.
It has one minute to record.
During that minute, the shop runs as usual. Order tracking asks order_events by request id, sixty times. That is MySQL, a million rows, and no index. The back office lists orders by status sixty times, and once with an or. Category pages ask for the products by category, six times. Product pages and the account page ask by SKU and by email, and they already have an index. And there is a list of ten customers, with no find at all.
The period ends. At the next tick, the loop looks at it, by itself. One index is created, and four query shapes are left alone. The index is in the script, and the script waits to run on this server. Left alone are small tables, fast and rare queries, shapes that no index can serve, and indexes that already exist. Here is the analysis of the period, on its Automatic indexes tab.
Seven shapes were recorded. Five had no index, one got an index, and four were left alone. You also see the settings it used. For order events, the index was created here, and written to the script. No index served the query. It was slower than a hundred milliseconds on average, with sixty calls, on nearly a million rows. The others were left alone, each with its reason. Orders has a hundred and eighty rows, so reading all of it is cheap.
A find with no condition reads every row. An or needs more than one index. And products by category had six calls, fast and rare. Nothing is indexed just in case. And here is the name of the index it built.
The rules always come in one order, the same on every server. A table in the exclusion list, or a table that cannot be read, is left alone. Then come the shapes that no single index can serve: an or, a text search, or an empty find. Then fast and rare queries, and small tables. Then a field that no index can hold, an index that already covers the query, the same index in the script, or a table with enough indexes.
What passes gets an index. The equal checks come first, then the in lists, then one range, and three fields at most.
The decision is also a line in a migration script. On the next page load, the panel says so: a migration script has not run on this server since it changed, am_index_maker. Every environment that deploys the project gets the same list, and its deploy runs it. Here, we run it from the card. Open it to see what the loop wrote. Create, on mysql, sales, order events, with the name, the field, the source Automatic, and the reason.
The script itself is TypeScript. It has the JSON list between two markers, which Index Maker rewrites, and the code that creates each index with g.sys.system.createIndexes. You can also add your own lines to the list. Click Run here. It runs on the databases of this server. The index is already there, so it is left alone. It says: applied here. The script lives in Git with the project. A pull that changes it marks it as not run on that server.
Then the deploy runs it, and the index is created, the first time. After that, it says exists, so nothing is created twice. So one reviewed list gives the same indexes on development, staging, and production.
Every index gets a name built from its table, its fields, and a hash of both. So the same definition gets the same name, in every environment. Each database has its length limit. Sixty four characters on MySQL and MariaDB, sixty three on PostgreSQL, a hundred and twenty eight on SQL Server, and a hundred on MongoDB. And thirty on Oracle, because its older versions need it. The words are cut evenly, but never the hash.
So an index is found by its name everywhere, and is never made twice.
Your own code can do the same with three system APIs. In API Testing, pick System APIs, then Create indexes. We send one definition: mysql, sales, order events, on order id and event type, with no name. It is created. The name is built for us, am_ix_order_events_order_id_event_type, with its hash. Send it again, and it says it exists already. Nothing is created twice. Now Get indexes, for the same table.
We see the primary key, the index of the automatic mode, and this new one, in one shape for every database. Now Drop indexes, by name. It is dropped. From a custom API, a migration, or a script, you call g.sys.system.createIndexes, getIndexes, and dropIndexes. The body is the same on six engines, and each index gets a status: created, exists, dropped, not found, skipped, or failed. Back in Index Maker, the index log shows the index of the automatic mode, and the create and drop of the system APIs.
Each line says who did it, and when.
Good to know. The next scan starts six hours after the last one ended. In a cluster, one server runs the loop each minute, through Redis. The suggestions and the index form of the last video write into the same script. And the script cannot be removed, because Index Maker owns it. Remove its lines instead.
There is one written order of rules, and a reason for every decision. Every index is a reviewed line in Git, the same in every environment. So a migration written by an AI assistant calls createIndexes, and never writes raw index statements for six databases.
To sum up. The automatic mode records and decides. Every query gets a reason. The script am_index_maker runs in every environment. Each index has one name on every database. And your code has Create, Get, and Drop indexes. Next: database migrations. API Maker. Build faster. Spend smarter. Deliver better.
Length 7:17Migrations
Length 5:30Why Rust
Length 15:18Built in
Length 7:03Scale out