I'm migrating my app from MySQL to Postgres. If I do a rake db:schema:load
, it loads fine into Postgres, and all my tests pass.
If I do rake db:migrate:reset
, then an integer column that I had previously set to have :limit => 1
is set to have :limit => 2
.
My migration sets it like so:
t.integer "foo", :limit => 1, :null => false
Is it simply a matter of Postgres having a lower minimum size?
Most developers will tell you that MySQL is better for websites and online transactions, while PostgreSQL is better for large and complicated analytical processes.
PostgreSQL vs MySQL: Speed Speed however is a benchmark that will be decided based on how the Database is being utilized. PostgreSQL is faster when dealing with massive datasets, complicated queries, and read-write operations. On the other hand, MySQL is known to be faster for read-only commands.
Previously, Postgres performance was more balanced, i.e., reads were generally slower than MySQL, but then it improved and can now write large amounts of data more efficiently, making concurrency handling better.
MySQL is more popular than PostgreSQL for historical reasons. These are the major ones (in retrospect): MySQL was more leaner and faster in some (widely used) use cases since it had less features. Even though it was not the best, MySQL's replication system was very simple to setup and maintain.
The smallint
type in PostgreSQL occupies two byte and accepts numbers from -32768 to +32767.
There is no tinyint
like in MySQL that occupies 1 byte and accepts numbers from -128 to 127.
Postgres doesn't provide a 1-byte integer type. The smallest datatype for integer is the 2-byte smallint.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With