PostgreSQL in Laravel: Faster/Better than MySQL?

preview_player
Показать описание
Video version of a long 14-minute-read premium article from Laravel Daily.

Support the channel by checking out my products:

Other places to follow:
Рекомендации по теме
Комментарии
Автор

I have successfully migrated various complexity projects from MySQL to PostgreSQL using PHPStorm built-in database tools. There are two methods to do this:

1) Direct Copy:
Right-click on the MySQL tables → Import/Export → Copy Table To...
Select your PostgreSQL connection and map the tables.

2) Export/Import via CSV:
Right-click on the MySQL tables → Import/Export → Export Data to Files.
Check Add column as header and export the files.
To import, follow the same steps but choose Import Data from Files.
Use the first row as column names and map the tables.

krims
Автор

Great video, can‘t wait to read through the article. I used the query builder and built an artisan command to help with the migration. Tested copying data from MySQL to PgSQL in Table Plus, which worked surprisingly well too. All in all I‘m excited for PgSQL, especially with all the extensions available.

theneverything
Автор

I am using PostgreSQL for more than 4 years. I can tell you if you want to have the most of a relational database then choose PostgreSQL otherwise MySQL is fine.

habibm
Автор

We use PostgreSQL as well. their jsonb, vector search and plugins are better than MySQL. Even their Boolean t or f is better in my opinion than 1 or 0

ParsclickTV
Автор

One more thing to note is. Enums are better in Postgres. But right now you have to write a bit of raw statements for Laravel to run migrations. The default enum column creates db check constraint instead of the Postgres Enum type. So in short Postgres make enums finally viable to use in your code. But Laravel needs to improve the migration syntax and make it easy.

SiddharthPant
Автор

Again, this is a "right tool for the job". If you have a write intensive application, or need some of the numerous special features/plugins for postgres, then go with that. If not, MySQL is fine.

Another thing to keep in mind is there are some querying differences. For example, doing a LIKE in MySQL is case-insensitive, where as in Postgres, it is case-sensitive. If you want a case-insensitive LIKE in Postgres, you use ILIKE.

JamieHollyHIT
Автор

Gotta start using Postgres. Been wanting too.

Our team is still a little caveman with progress unfortunately.

rtothec
Автор

Hey Povilas, just a quick side not, you think buying individual articles could be an option in the future? Thanks

SaiyanJin
Автор

I use a lot of raw queries when dealing with geospatial queries, I was planning to move to postgreSQL but the migration seems a lot of work.

parihar-shashwat
Автор

I haven't used MySQL (or MariaDB) in ages, I switched to Postgres for its richer feature set, and the RLS (Row-Level Security) is simply unbeatable 🔥

ricko
Автор

I have a question. You mentioned that you "test for a large enough project". What do you consider a "large enough project" to be? Number of tables, users, servers, microservices?

Andris_Briedis
Автор

Thanks for the video. I may have missed that point or you didn't say. But what do you mainly use? PostgreSQL or MySQL?

DmytroSkoryk
Автор

All my small projects are in mySQL, and it's still the easiest way to starting (i use Sail on Linux). My doubt is: if i don't use raw queries, it's a possiblity to develop locally in mysql and then ship in laravel cloud with postgreSQL?

Is it too risky?

capins
Автор

We use postgresql on my work and i usually work with mysql. I can see how difference the query speed is

maruatajongte
Автор

The Laravel company wants to become more like Vercel and Postgres is their choice 😮

codernerd
Автор

I think there is nothing wrong with mariadb/mysql nor PostgreSQL, speed in specific cases is not everything, if it was, we would be talking exclusively noSql here

As_Ss
Автор

I guess even more noticable this will become when rps will rise.

groovyboytube
Автор

My favorite feature that Psql and SQLite have while MySQL does not is conditional indexes, eg create unique index users_email on users(email) where deleted_at is null;

Denakino
Автор

How do you seed a DB with 200k records, normal laravel seeders?

wilhelmtell
Автор

I used Sql server on laravel projects much faster than mysql

gtsmeg