0
I have the following situation with the tables below. I need to do some checking in "serials" (if the serial exists, if it is valid, etc, and other validations next to other tables) from several serials (up to thousands at a time) and, if not valid, register in "serials_errors" the serial ID (if it is registered) or the serial itself, if it is not registered and is not valid.
What is the most appropriate way to solve this, since I need to treat each serial separately? As it comes to thousands of serials each time, I worry a lot about performance.
CREATE TABLE IF NOT EXISTS `seriais` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`serial` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `serial_erros` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`serial_id` int(11) NOT NULL,
`serial` int(11) NOT NULL,
`erro` text NOT NULL,
PRIMARY KEY (`id`),
KEY `serial_id` (`serial_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Are there any indexes for this table ? What ? Also study the use of EXISTS
– Motta
Well there are several ways to prepare Neston, but in your case, ever thought of creating a View that links the 2 tables, would give you a much faster result in searches.
– Marcelo Welter
In this case it is recommended to define the field
serial
as a table index, for large-scale searches. What exactly do you mean byusando o WHERE IN
? What I see there is a consultation SQL normal using only SQL. In a general context, what is really related to doubt ?– Edilson