Using small integers instead of entire class strings for morph relations can improve their performance

Using small integers instead of entire class strings for morph relations can improve their performance

When using Laravel morphs, you can eek out some extra performance by using small integers instead of strings for your morph types.

Smaller, faster indexes for the database to manage!

Especially useful for tables like comments or audits, which can be many millions of rows.

We're writing a book, you can get it for free here.