app_files table
+-----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+----------------+
| file_id | int(10) | NO | PRI | NULL | auto_increment |
| file_name | varchar(255) | NO | | NULL | |
| file_data | longblob | NO | | NULL | |
+-----------+--------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)
If I add 10,000 images to this table and lookup images based on file_id, will the performance
suffer?
I already know it is NOT recommend to store files in the database, but I need this to work with backups in one place.
No, the performance will be good, since you’re querying on Primary Key, which is already indexed.
However, if you plan to do query on file_name, don’t forget to create an index on that field.
And don’t do queries on file_data 🙂