【发布时间】:2019-02-18 12:25:45
【问题描述】:
由于某种原因,在我的数据库中的特定表中,插入一行大约需要 30 秒。
问题是,在我查看表格之前,每列文本都设置为 textarea,所以我更新了它以查看它是否提高了性能,但没有。
我也用复制表完成了它,因为它有一个插入到之前的触发器,它也有相同的配置问题。
但是,它仍然会出现问题。
有查询
INSERT IGNORE INTO bbdd_gestion_new.publicados
(sku, referencia, cantidad, estado_amazon,
estado_ebay, EAN, ASIN, titulo, tipo,
preciocompra, preciocompra_b, precioventa, precioamazon,
short_description, short_description_en, short_description_de, descripcion,
familiatienda,
familiaebay, imagen, fecha,
portes_N, portes_I1, portes_I2, revision, comentarios, ubicacion,
peso, usuario, marca)
VALUES
('6920702794790-R', 'W17-BM5047', '1', 'No publicar', '7000',
'6920702794790', 'B00K0EI562',
'Huawei E3131H - Llave Bluetooth 3G, color blanco.',
'Retourware',
'2.85', '2.85', '4.99', '0',
'PRODUCTO RETOUR-WARE – Artículo original completo procedente de devolución. Su funcionamiento no ha sido comprobado. Puede mostrar signos de desgaste y/o carecer de su embalaje original e instrucciones. No ha sido aperturado ni manipulado para el aprovechamiento de sus componentes.',
'PRODUCT RETOUR-WARE – Original item originating from return. Its operation has not been proven. It may show signs of wear and / or lack of its original packaging and instructions. It has not been opened or manipulated for the use of its components.',
'PRODUKT RETOUR-WARE – Originalartikel, der von der Rücksendung stammt. Seine Funktionsweise wurde nicht nachgewiesen. Es kann Anzeichen von Verschleiß und / oder das Fehlen der Originalverpackung und der Gebrauchsanweisung aufweisen. Es wurde für die Verwendung seiner Komponenten nicht geöffnet oder manipuliert.',
' Huawei E3131 Llave 3 G soltarse todo operadorHSPA +/HSPA/UMTS/GSM/GPRS/EDGE',
'Informatica>Categorias>Dispositivos de red>Adaptadores de red', '667049031>667050031>937958031>937959031',
'https://images-eu.ssl-images-amazon.com/images/I/31sZA-aS1fL._SL160_.jpg',
'2019-02-18 13:12:01', '3.99', '9.99', '9.99', '',
'producto subido por cron_publicar_rotos',
'', '1', 'user', 'Huawei');
有问题的表。
CREATE TABLE IF NOT EXISTS `publicados` (
`sku` varchar(20) NOT NULL,
`referencia` varchar(20) NOT NULL,
`cantidad` int(11) NOT NULL,
`estado_amazon` varchar(64) NOT NULL,
`estado_ebay` int(11) NOT NULL,
`EAN` varchar(24) NOT NULL,
`ASIN` varchar(24) NOT NULL,
`titulo` varchar(70) NOT NULL,
`tipo` varchar(15) NOT NULL,
`preciocompra` decimal(8,2) unsigned NOT NULL,
`preciocompra_b` decimal(8,2) NOT NULL,
`precioventa` decimal(8,2) NOT NULL,
`precioamazon` decimal(8,2) NOT NULL,
`short_description` varchar(256) NOT NULL,
`short_description_en` varchar(256) DEFAULT NULL,
`short_description_de` varchar(256) DEFAULT NULL,
`descripcion` varchar(4096) NOT NULL,
`familiatienda` varchar(100) NOT NULL,
`familiaebay` varchar(100) NOT NULL,
`imagen` varchar(100) NOT NULL,
`fecha` datetime NOT NULL,
`portes_N` decimal(8,2) NOT NULL,
`portes_I1` decimal(8,2) NOT NULL,
`portes_I2` decimal(8,2) NOT NULL,
`revision` varchar(1) NOT NULL,
`comentarios` varchar(256) NOT NULL,
`ubicacion` varchar(20) DEFAULT NULL,
`peso` decimal(6,3) NOT NULL,
`usuario` varchar(20) DEFAULT NULL,
`marca` varchar(24) DEFAULT NULL,
PRIMARY KEY (`referencia`),
KEY `cantidad` (`cantidad`),
KEY `sku` (`sku`),
KEY `ubicacion` (`ubicacion`),
KEY `fecha` (`fecha`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
我正在使用 PHP 5.3 和 HeidiSQL 之类的查看器。 还有警告
警告:第 1 行的“short_description”列的数据被截断
警告:第 1 行的“short_description_de”列的数据被截断
【问题讨论】:
-
mySQL 使用 php 和 heidiSQL 访问
-
你在使用索引吗?
-
那个索引是配置PRIMARY KEY (
referencia), KEYcantidad(cantidad), KEYsku(sku), KEYubicacion(ubicacion) , 键fecha(fecha) -
几乎没有任何事情可以导致单行
INSERT花费 30 秒。是否同时发生了其他事情?尤其是同一张桌子?问题是否再次出现? -
无特定进程 有时会持续 30 秒,再持续 40 秒。整个服务器正常工作,除非您插入该特定表。
标签: php mysql sql performance triggers