database-optimization

Does InnoDB have static tables?

纵然是瞬间 提交于 2020-06-17 03:40:47
问题 I was reading MySQL documentation and I was wondering whether MyISAM's "static" table format also applies on InnoDB or not? Do I gain performance, if I use CHAR instead of VARCHAR when the real lengths varies between 0 and 100 characters or is using VARCHAR(100) better? 回答1: InnoDB does have fixed-width rows and there can be some advantage to declaring all columns in a table as fixed-width. The main benefit is that all "holes" in a page can be reused for any insertion, since all rows are the

Does InnoDB have static tables?

孤街浪徒 提交于 2020-06-17 03:37:45
问题 I was reading MySQL documentation and I was wondering whether MyISAM's "static" table format also applies on InnoDB or not? Do I gain performance, if I use CHAR instead of VARCHAR when the real lengths varies between 0 and 100 characters or is using VARCHAR(100) better? 回答1: InnoDB does have fixed-width rows and there can be some advantage to declaring all columns in a table as fixed-width. The main benefit is that all "holes" in a page can be reused for any insertion, since all rows are the

Does InnoDB have static tables?

百般思念 提交于 2020-06-17 03:36:06
问题 I was reading MySQL documentation and I was wondering whether MyISAM's "static" table format also applies on InnoDB or not? Do I gain performance, if I use CHAR instead of VARCHAR when the real lengths varies between 0 and 100 characters or is using VARCHAR(100) better? 回答1: InnoDB does have fixed-width rows and there can be some advantage to declaring all columns in a table as fixed-width. The main benefit is that all "holes" in a page can be reused for any insertion, since all rows are the

How to save one Doctrine entity to two database tables (required for MySQL optimisation)

流过昼夜 提交于 2020-01-25 11:43:09
问题 In my database I've a table file and a table file_content . The file table stores the metadata of the file such as name , mime and some more. The file_content stores a blob with the file content. I'm not storing the blob in the same table as the metadata for performance reasons only. For a 'version 2' of my project I'm looking into Doctrine (2.3). To me, a "File" seems to be one entity, with properties such as name , mime , extension , content that should be used like this: $file = new File()

How to save one Doctrine entity to two database tables (required for MySQL optimisation)

心不动则不痛 提交于 2020-01-25 11:42:30
问题 In my database I've a table file and a table file_content . The file table stores the metadata of the file such as name , mime and some more. The file_content stores a blob with the file content. I'm not storing the blob in the same table as the metadata for performance reasons only. For a 'version 2' of my project I'm looking into Doctrine (2.3). To me, a "File" seems to be one entity, with properties such as name , mime , extension , content that should be used like this: $file = new File()

How much size I will save if changed INT column to MEDIUMINT?

三世轮回 提交于 2019-12-23 02:34:36
问题 I'm learning how to optimize my database by re choosing the correct data types for the columns and I want to know how much size I will save if I choose MEDIUMINT (3 Bytes) instead of INT (4 Bytes) AFAIK -and correct me if I'm wrong- I need the database size to be as small as possible to fit in RAM to reduce the hard-desk requests. The size of the database consists of the tables sizes + index sizes giving that I have an INT column that has 10'000'000 rows and a B-Tree index on it, how much

Best way to count rows from mysql database

ε祈祈猫儿з 提交于 2019-12-13 14:06:12
问题 After facing a slow loading time issue with a mysql query, I'm now looking the best way to count rows numbers. I have stupidly used mysql_num_rows() function to do this and now realized its a worst way to do this. I was actually making a Pagination to make pages in PHP. I have found several ways to count rows number. But I'm looking the faster way to count it. The table type is MyISAM So the question is now Which is the best and faster to count - 1. `SELECT count(*) FROM 'table_name'` 2.

Need Help for Optimizing MySQL query with few joins

六眼飞鱼酱① 提交于 2019-12-12 06:49:40
问题 Hello I have the follow sql query it works but it is kind of slow SELECT ep . *, t_u.sUsername AS sLockedBy, epi.sName, em.sName AS sManufacturerName, SUM(IF(eop.dInProduction IS NULL AND eop.dFromProduction IS NULL AND eop.dShipped IS NULL AND eop.nIsCancelled = 0 AND eos.sStatusCode NOT IN ('Canceled' , 'Finished', 'Complete'), 1, 0)) AS nProductOrdered, SUM(IF(eop.dInProduction IS NOT NULL AND eop.dFromProduction IS NULL AND eop.dShipped IS NULL AND eop.nIsCancelled = 0 AND eos.sStatusCode

Advantages of having user authentication details stored in a separate table

有些话、适合烂在心里 提交于 2019-12-10 18:06:29
问题 I have a user table in mysql containing all user data (firstname, surname, address, etc) But should I store the authentication details in another table (username, password) and link the two tables via a user ID? Is there much point in this? Is it more secure? or does it just add extra coding? 回答1: Is there much point in this? Nope, not at all. Is it more secure? If someone can access your users table they can surely access whatever other table the passwords are on, so no. or does it just add

Which of the following SQL queries would be faster? A join on two tables or successive queries?

落爺英雄遲暮 提交于 2019-12-10 17:54:33
问题 I have two tables here: ITEMS ID| DETAILS| .....| OWNER USERS: ID| NAME|.... Where ITEMS.OWNER = USERS.ID I'm listing the items out with their respective owners names. For this I could use a join on both tables or I could select all the ITEMS and loop through them making a sql query to retrieve the tuple of that itmes owner. Thats like: 1 sql with a JOIN versus 1x20 single table sql queries Which would be a better apporach to take in terms of speed? Thanks 回答1: Every query has overhead. If