MyISAM

Optimizing MySQL queries with IN operator

怎甘沉沦 提交于 2019-12-25 03:40:00
问题 I have a MySQL database with a fairly large table where the products are. Each of them has its own id and categoryId field where there is a category id belongs to this product. Now I have a query that pulls out products from given categories such as: SELECT * FROM products WHERE categoryId IN ( 1, 2, 3, 4, 5, 34, 6, 7, 8, 9, 10, 11, 12 ) Of course, come a WHERE clause and ORDER BY sort but not in this thing. Let's say that these products is 250k and the visits are over 100k per day. Under

How to convert MAIN mysql database to InnoDB from MyIsam

点点圈 提交于 2019-12-24 23:53:57
问题 I am trying to manage mysql group replication and I noticed a problem when manipulating users and grants . 10 of the main mysql tables in the main mysql database are MyIsam. So I cant add databases or user permissions because they fail and wont replicate. Master-master group replication requirs everything InnoDB. ALTER TABLE works fine on regular custom databases/tables but how do you fix this on the main mysql database? I tried this but they all fail: ALTER TABLE mysql.db ENGINE = InnoDB;

数据库中COUNT(*)的执行原理

*爱你&永不变心* 提交于 2019-12-24 23:40:52
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 来源: https://url.cn/5zSuErM “SELECT COUNT( ) FROM t” 是个再常见不过的 SQL 需求了。在 MySQL 的使用规范中,我们一般使用事务引擎 InnoDB 作为(一般业务)表的存储引擎,在此前提下,COUNT( )操作的时间复杂度为 O(N),其中 N 为表的行数。 而 MyISAM 表中可以快速取到表的行数。这些实践经验的背后是怎样的机制,以及为什么需要/可以是这样,就是此文想要探讨的。 先来看一下概况: MySQL COUNT(*) 在 2 种存储引擎中的部分问题: 下面就带着这些问题,以 InnoDB 存储引擎为主来进行讨论。 一、InnoDB 全表 COUNT(*) 执行过程是怎样的? **①、**如何计算 count?影响 count 结果的因素有哪些? **②、**count 值存在哪里?涉及的数据结构是怎样的? **③、**为什么 InnoDB 只能通过扫表来实现 count(*)?(见本文最后的问题) **④、**全表COUNT(*)作为 table scan 类型操作的一个 case,有什么风险? **⑤、**COUNT(*)操作是否会像“SELECT * ”一样可能读取大字段涉及的溢出页? 1、执行框架 – 循环: 读取 + 计数 1.1

SQL Inner Join : DB stuck

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 17:24:58
问题 I postet this question a few days ago but I didn't explain exactly what I want. I ask the question better formulated again: To clarify my problem I added some new information: I got an MySQL DB with MyISAM tables. The two relevant tables are: * orders_products: orders_products_id, orders_id, product_id, product_name, product_price, product_name, product_model, final_price, ... * products: products_id, manufacturers_id, ... (for full information about the tables see screenshot products

incremental counter mysql

爱⌒轻易说出口 提交于 2019-12-24 13:52:42
问题 My question is pretty simple but answer might be tricky. I'm in PHP and I want to manage manually a unique ID for my objects. What is tricky is to manage atomicity. I dont want that 2 elements get the same ID. "Elements" are grouped in "Groups". In each group I want elements ID starting from 1 and grow incrementally for each insert in that group. My first solution is to have a "lastID" column in the table "Groups" : CREATE TABLE groups ( id INT AUTO_INCREMENT, lastId INT ) CREATE TABLE

What is the best way to periodically load data into table

雨燕双飞 提交于 2019-12-24 11:29:31
问题 I have a database with static tables which require to be updated from CSV weekly. Tables are Mysql MyISAM and by static i mean they are used for read only (except when updated from CVS, obviously). There're about 50 tables and in total about 200mb of data to be reloaded weekly. I can think about 3 ways: Truncate table Load data from files Or For each table create a temporary table Load data there Truncate (or delete rows?) original table Insert into original table select * from temporary

Why is myisam storage engine is faster than Innodb storage engine

冷暖自知 提交于 2019-12-24 10:58:54
问题 Why is myisam storage engine is faster than Innodb storage engine what makes it to be faster and innodb to be slow? 回答1: MyISAM can be faster than innodb because it has a simpler design. Also it has been around a much longer time, and has more time to accumulate incremental improvements and optimizations based on data on real usage. Design of MyISAM is based on ISAM: http://en.m.wikipedia.org/wiki/ISAM The speed comes with a price though: MyISAM does not support transactions or foreign keys.

Post optimization needed after deleting rows in a MYSQL Database

吃可爱长大的小学妹 提交于 2019-12-24 09:00:41
问题 I have a log table that is currently 10GB. It has a lot of data for the past 2 years, and I really feel at this point I don't need so much in there. Am I wrong to assume it is not good to have years of data in a table (a smaller table is better)? My tables all have an engine of MYISAM. I would like to delete all data of 2014 and 2015, and soon i'll do 2016, but i'm concerned about after I run the DELETE statement, what exactly will happen. I understand because it's ISAM there is a lock that

Am I right that InnoDb is better for frequent concurrent updates and inserts than MyISAM?

感情迁移 提交于 2019-12-24 02:39:07
问题 We have a websites with hundreds of visitors every day and tens of thousands queries a day. So, some tables in the database are updated very rarely, some tables are updated few times a minute and some tables are updated ~10 times a seconds. MyISAM uses table-level locking for updates and InnoDb uses row-level locking. So, as I understand, for tables with frequent concurrent updates (several updates per second) it is better to make them InnoDb, and for other tables (if we don't need

Migrating Spring Batch MyISAM Sequence Tables to InnoDB

允我心安 提交于 2019-12-24 02:19:07
问题 Spring batch uses a few sequence tables, which in the case of MySQL use the MyISAM storage engine. The issue I'm facing is that I'm using an Amazon Web Services RDS database, and their "Point in Time" database restore feature does not play nicely with databases containing MyISAM tables. I'm looking for a solution that will let me switch out these Spring Batch MyISAM sequence tables and replacing them with InnoDB tables instead, with the goal of enabling the AWS RDS "Point in Time" database