Is there a way to optimize this query? JOIN with several rows in MySQLHow to output MySQL query results in CSV format?MySQL Limit LEFT JOIN Subquery after joiningOptimize multiple JOINs in MySQLJOIN Query In MYSQL and PHPOptimization Needed For Dual Left Join QueryNeed help in SQL query performanceMYSQL Error Installing BuildEnginePHP artisan migrate command giving errors?desc table in mysql say Null is No but default is NULL?How to optimize a select query with multiple left joins in a large database
Would it be illegal for Facebook to actively promote a political agenda?
Why does AC run even when it is cooler outside than in?
How could China have extradited people for political reason under the extradition law it wanted to pass in Hong Kong?
How can I pack my food so it doesn't smell?
Story that includes a description: "Two concentric circles, intersecting at three points"
Repurpose telephone line to ethernet
Is there a commercial liquid with refractive index greater than n=2?
Are there categories whose internal hom is somewhat 'exotic'?
Have only girls been born for a long time in this village?
How can I train a replacement without letting my bosses and the replacement know?
Cheap storage lockers in Tromsø, Norway
Levenshtein Neighbours
How to decide whether an eshop is safe or compromised
How can I override the serving of Media Files? (Implementing authentication for media items)
Interaction between Ethereal Absolution versus Edgar Markov with Captivating Vampire
Do living authors still get paid royalties for their old work?
What animal has fat with the highest energy density?
Is a butterfly one or two animals?
Unity: transform.LookAt(target) not "looking at" target?
!I!n!s!e!r!t! !n!b!e!t!w!e!e!n!
Why the color Red in Us, what is the significance?
Syncing bitcoin node with multiple cores
Can others monetize my project with GPLv3?
90s(?) book series about two people transported to a parallel medieval world, she joins city watch, he becomes wizard
Is there a way to optimize this query? JOIN with several rows in MySQL
How to output MySQL query results in CSV format?MySQL Limit LEFT JOIN Subquery after joiningOptimize multiple JOINs in MySQLJOIN Query In MYSQL and PHPOptimization Needed For Dual Left Join QueryNeed help in SQL query performanceMYSQL Error Installing BuildEnginePHP artisan migrate command giving errors?desc table in mysql say Null is No but default is NULL?How to optimize a select query with multiple left joins in a large database
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I need to make this query:
SELECT min(d.id) id, p.SERIAL serial, p.pos_id pos_id, MIN(fecha) fecha
FROM pvs p
JOIN devices d
ON d.SERIAL=p.SERIAL
GROUP BY p.SERIAL, p.pos_id
ORDER BY p.pos_id ASC;
The issue is that "pvs" is a very long table with plus 3 million rows. It's a table where I upload raw data but then I try to get the id of these elements in the working database (hence the min(d.id) part). that's also the reason why I didn't add a foreign key as such on pos_id in pvs.
The structure is the following:
CREATE TABLE pvs (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`pos_id` INT(11) NOT NULL,
`estado` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_ci',
`fecha` DATETIME NOT NULL,
`serial` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_ci',
`created_at` TIMESTAMP NULL DEFAULT NULL,
`updated_at` TIMESTAMP NULL DEFAULT NULL
)
CREATE TABLE devices (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`serial` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`rotulo` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`code` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`cost_center` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`guia_recepcion` INT(11) NULL DEFAULT NULL,
`guia_reversa` INT(11) NULL DEFAULT NULL,
`pep` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`modified_by` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`modified_on` DATETIME NULL DEFAULT NULL,
`fecha_recepcion` DATETIME NULL DEFAULT NULL,
`fecha_instalacion` DATETIME NULL DEFAULT NULL,
`fecha_reversa` DATETIME NULL DEFAULT NULL,
`status_id` INT(10) UNSIGNED NOT NULL,
`location_id` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_ci',
`customer_id` INT(10) UNSIGNED NOT NULL,
`str_id` INT(10) UNSIGNED NOT NULL,
`model_id` INT(10) UNSIGNED NOT NULL,
`pos_id` INT(11) NOT NULL,
`user_id` INT(10) UNSIGNED NOT NULL,
`technician_id` INT(10) UNSIGNED NOT NULL,
`created_at` TIMESTAMP NULL DEFAULT NULL,
`updated_at` TIMESTAMP NULL DEFAULT NULL,
`serial_prev` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`reversa_prev` DATETIME NULL DEFAULT NULL
)
Should I make p.serial a foreign key even though it's a varchar? If I just use p.pos_id as join clause "ids" are the same. I grouped it with min() because I needed to add it to the select without adding it to the "group by". I need the same columns for the query.
EDIT:

mysql
add a comment |
I need to make this query:
SELECT min(d.id) id, p.SERIAL serial, p.pos_id pos_id, MIN(fecha) fecha
FROM pvs p
JOIN devices d
ON d.SERIAL=p.SERIAL
GROUP BY p.SERIAL, p.pos_id
ORDER BY p.pos_id ASC;
The issue is that "pvs" is a very long table with plus 3 million rows. It's a table where I upload raw data but then I try to get the id of these elements in the working database (hence the min(d.id) part). that's also the reason why I didn't add a foreign key as such on pos_id in pvs.
The structure is the following:
CREATE TABLE pvs (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`pos_id` INT(11) NOT NULL,
`estado` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_ci',
`fecha` DATETIME NOT NULL,
`serial` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_ci',
`created_at` TIMESTAMP NULL DEFAULT NULL,
`updated_at` TIMESTAMP NULL DEFAULT NULL
)
CREATE TABLE devices (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`serial` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`rotulo` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`code` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`cost_center` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`guia_recepcion` INT(11) NULL DEFAULT NULL,
`guia_reversa` INT(11) NULL DEFAULT NULL,
`pep` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`modified_by` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`modified_on` DATETIME NULL DEFAULT NULL,
`fecha_recepcion` DATETIME NULL DEFAULT NULL,
`fecha_instalacion` DATETIME NULL DEFAULT NULL,
`fecha_reversa` DATETIME NULL DEFAULT NULL,
`status_id` INT(10) UNSIGNED NOT NULL,
`location_id` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_ci',
`customer_id` INT(10) UNSIGNED NOT NULL,
`str_id` INT(10) UNSIGNED NOT NULL,
`model_id` INT(10) UNSIGNED NOT NULL,
`pos_id` INT(11) NOT NULL,
`user_id` INT(10) UNSIGNED NOT NULL,
`technician_id` INT(10) UNSIGNED NOT NULL,
`created_at` TIMESTAMP NULL DEFAULT NULL,
`updated_at` TIMESTAMP NULL DEFAULT NULL,
`serial_prev` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`reversa_prev` DATETIME NULL DEFAULT NULL
)
Should I make p.serial a foreign key even though it's a varchar? If I just use p.pos_id as join clause "ids" are the same. I grouped it with min() because I needed to add it to the select without adding it to the "group by". I need the same columns for the query.
EDIT:

mysql
isd.serialunique ?
– Cid
Mar 27 at 14:45
No, it's not. It can show up in several ids.
– ffuentes
Mar 27 at 14:46
What aboutp.serial? is it unique ?
– Cid
Mar 27 at 14:47
No it's not. That table tracks the status of a device in a location and actually they repeat a lot.
– ffuentes
Mar 27 at 14:50
add a comment |
I need to make this query:
SELECT min(d.id) id, p.SERIAL serial, p.pos_id pos_id, MIN(fecha) fecha
FROM pvs p
JOIN devices d
ON d.SERIAL=p.SERIAL
GROUP BY p.SERIAL, p.pos_id
ORDER BY p.pos_id ASC;
The issue is that "pvs" is a very long table with plus 3 million rows. It's a table where I upload raw data but then I try to get the id of these elements in the working database (hence the min(d.id) part). that's also the reason why I didn't add a foreign key as such on pos_id in pvs.
The structure is the following:
CREATE TABLE pvs (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`pos_id` INT(11) NOT NULL,
`estado` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_ci',
`fecha` DATETIME NOT NULL,
`serial` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_ci',
`created_at` TIMESTAMP NULL DEFAULT NULL,
`updated_at` TIMESTAMP NULL DEFAULT NULL
)
CREATE TABLE devices (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`serial` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`rotulo` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`code` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`cost_center` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`guia_recepcion` INT(11) NULL DEFAULT NULL,
`guia_reversa` INT(11) NULL DEFAULT NULL,
`pep` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`modified_by` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`modified_on` DATETIME NULL DEFAULT NULL,
`fecha_recepcion` DATETIME NULL DEFAULT NULL,
`fecha_instalacion` DATETIME NULL DEFAULT NULL,
`fecha_reversa` DATETIME NULL DEFAULT NULL,
`status_id` INT(10) UNSIGNED NOT NULL,
`location_id` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_ci',
`customer_id` INT(10) UNSIGNED NOT NULL,
`str_id` INT(10) UNSIGNED NOT NULL,
`model_id` INT(10) UNSIGNED NOT NULL,
`pos_id` INT(11) NOT NULL,
`user_id` INT(10) UNSIGNED NOT NULL,
`technician_id` INT(10) UNSIGNED NOT NULL,
`created_at` TIMESTAMP NULL DEFAULT NULL,
`updated_at` TIMESTAMP NULL DEFAULT NULL,
`serial_prev` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`reversa_prev` DATETIME NULL DEFAULT NULL
)
Should I make p.serial a foreign key even though it's a varchar? If I just use p.pos_id as join clause "ids" are the same. I grouped it with min() because I needed to add it to the select without adding it to the "group by". I need the same columns for the query.
EDIT:

mysql
I need to make this query:
SELECT min(d.id) id, p.SERIAL serial, p.pos_id pos_id, MIN(fecha) fecha
FROM pvs p
JOIN devices d
ON d.SERIAL=p.SERIAL
GROUP BY p.SERIAL, p.pos_id
ORDER BY p.pos_id ASC;
The issue is that "pvs" is a very long table with plus 3 million rows. It's a table where I upload raw data but then I try to get the id of these elements in the working database (hence the min(d.id) part). that's also the reason why I didn't add a foreign key as such on pos_id in pvs.
The structure is the following:
CREATE TABLE pvs (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`pos_id` INT(11) NOT NULL,
`estado` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_ci',
`fecha` DATETIME NOT NULL,
`serial` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_ci',
`created_at` TIMESTAMP NULL DEFAULT NULL,
`updated_at` TIMESTAMP NULL DEFAULT NULL
)
CREATE TABLE devices (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`serial` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`rotulo` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`code` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`cost_center` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`guia_recepcion` INT(11) NULL DEFAULT NULL,
`guia_reversa` INT(11) NULL DEFAULT NULL,
`pep` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`modified_by` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`modified_on` DATETIME NULL DEFAULT NULL,
`fecha_recepcion` DATETIME NULL DEFAULT NULL,
`fecha_instalacion` DATETIME NULL DEFAULT NULL,
`fecha_reversa` DATETIME NULL DEFAULT NULL,
`status_id` INT(10) UNSIGNED NOT NULL,
`location_id` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_ci',
`customer_id` INT(10) UNSIGNED NOT NULL,
`str_id` INT(10) UNSIGNED NOT NULL,
`model_id` INT(10) UNSIGNED NOT NULL,
`pos_id` INT(11) NOT NULL,
`user_id` INT(10) UNSIGNED NOT NULL,
`technician_id` INT(10) UNSIGNED NOT NULL,
`created_at` TIMESTAMP NULL DEFAULT NULL,
`updated_at` TIMESTAMP NULL DEFAULT NULL,
`serial_prev` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
`reversa_prev` DATETIME NULL DEFAULT NULL
)
Should I make p.serial a foreign key even though it's a varchar? If I just use p.pos_id as join clause "ids" are the same. I grouped it with min() because I needed to add it to the select without adding it to the "group by". I need the same columns for the query.
EDIT:

mysql
mysql
edited Mar 27 at 14:55
ffuentes
asked Mar 27 at 14:40
ffuentesffuentes
3601 gold badge7 silver badges17 bronze badges
3601 gold badge7 silver badges17 bronze badges
isd.serialunique ?
– Cid
Mar 27 at 14:45
No, it's not. It can show up in several ids.
– ffuentes
Mar 27 at 14:46
What aboutp.serial? is it unique ?
– Cid
Mar 27 at 14:47
No it's not. That table tracks the status of a device in a location and actually they repeat a lot.
– ffuentes
Mar 27 at 14:50
add a comment |
isd.serialunique ?
– Cid
Mar 27 at 14:45
No, it's not. It can show up in several ids.
– ffuentes
Mar 27 at 14:46
What aboutp.serial? is it unique ?
– Cid
Mar 27 at 14:47
No it's not. That table tracks the status of a device in a location and actually they repeat a lot.
– ffuentes
Mar 27 at 14:50
is
d.serial unique ?– Cid
Mar 27 at 14:45
is
d.serial unique ?– Cid
Mar 27 at 14:45
No, it's not. It can show up in several ids.
– ffuentes
Mar 27 at 14:46
No, it's not. It can show up in several ids.
– ffuentes
Mar 27 at 14:46
What about
p.serial ? is it unique ?– Cid
Mar 27 at 14:47
What about
p.serial ? is it unique ?– Cid
Mar 27 at 14:47
No it's not. That table tracks the status of a device in a location and actually they repeat a lot.
– ffuentes
Mar 27 at 14:50
No it's not. That table tracks the status of a device in a location and actually they repeat a lot.
– ffuentes
Mar 27 at 14:50
add a comment |
1 Answer
1
active
oldest
votes
be sure you have proper index
create index idx1 on pvs( SERIAL);
and
create index idx2 on devices ( SERIAL);
Then it's not the answer.
– ffuentes
Mar 27 at 14:53
why can't be indexed ???? the indexes can be unique or not unique and in this case two not unique index can resolve the performace problem ..
– scaisEdge
Mar 27 at 14:53
The index can be or uniqie or not unique ... the unioque is just a constrain for an index ..as you can see in mysql doc dev.mysql.com/doc/refman/8.0/en/create-index.html unique is an option ..
– scaisEdge
Mar 27 at 14:55
So I'll try it and I'll tell you how it went...
– ffuentes
Mar 27 at 14:56
answer updated .. with index create commands
– scaisEdge
Mar 27 at 14:58
|
show 7 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55379936%2fis-there-a-way-to-optimize-this-query-join-with-several-rows-in-mysql%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
be sure you have proper index
create index idx1 on pvs( SERIAL);
and
create index idx2 on devices ( SERIAL);
Then it's not the answer.
– ffuentes
Mar 27 at 14:53
why can't be indexed ???? the indexes can be unique or not unique and in this case two not unique index can resolve the performace problem ..
– scaisEdge
Mar 27 at 14:53
The index can be or uniqie or not unique ... the unioque is just a constrain for an index ..as you can see in mysql doc dev.mysql.com/doc/refman/8.0/en/create-index.html unique is an option ..
– scaisEdge
Mar 27 at 14:55
So I'll try it and I'll tell you how it went...
– ffuentes
Mar 27 at 14:56
answer updated .. with index create commands
– scaisEdge
Mar 27 at 14:58
|
show 7 more comments
be sure you have proper index
create index idx1 on pvs( SERIAL);
and
create index idx2 on devices ( SERIAL);
Then it's not the answer.
– ffuentes
Mar 27 at 14:53
why can't be indexed ???? the indexes can be unique or not unique and in this case two not unique index can resolve the performace problem ..
– scaisEdge
Mar 27 at 14:53
The index can be or uniqie or not unique ... the unioque is just a constrain for an index ..as you can see in mysql doc dev.mysql.com/doc/refman/8.0/en/create-index.html unique is an option ..
– scaisEdge
Mar 27 at 14:55
So I'll try it and I'll tell you how it went...
– ffuentes
Mar 27 at 14:56
answer updated .. with index create commands
– scaisEdge
Mar 27 at 14:58
|
show 7 more comments
be sure you have proper index
create index idx1 on pvs( SERIAL);
and
create index idx2 on devices ( SERIAL);
be sure you have proper index
create index idx1 on pvs( SERIAL);
and
create index idx2 on devices ( SERIAL);
edited Mar 27 at 14:57
answered Mar 27 at 14:51
scaisEdgescaisEdge
107k10 gold badges55 silver badges75 bronze badges
107k10 gold badges55 silver badges75 bronze badges
Then it's not the answer.
– ffuentes
Mar 27 at 14:53
why can't be indexed ???? the indexes can be unique or not unique and in this case two not unique index can resolve the performace problem ..
– scaisEdge
Mar 27 at 14:53
The index can be or uniqie or not unique ... the unioque is just a constrain for an index ..as you can see in mysql doc dev.mysql.com/doc/refman/8.0/en/create-index.html unique is an option ..
– scaisEdge
Mar 27 at 14:55
So I'll try it and I'll tell you how it went...
– ffuentes
Mar 27 at 14:56
answer updated .. with index create commands
– scaisEdge
Mar 27 at 14:58
|
show 7 more comments
Then it's not the answer.
– ffuentes
Mar 27 at 14:53
why can't be indexed ???? the indexes can be unique or not unique and in this case two not unique index can resolve the performace problem ..
– scaisEdge
Mar 27 at 14:53
The index can be or uniqie or not unique ... the unioque is just a constrain for an index ..as you can see in mysql doc dev.mysql.com/doc/refman/8.0/en/create-index.html unique is an option ..
– scaisEdge
Mar 27 at 14:55
So I'll try it and I'll tell you how it went...
– ffuentes
Mar 27 at 14:56
answer updated .. with index create commands
– scaisEdge
Mar 27 at 14:58
Then it's not the answer.
– ffuentes
Mar 27 at 14:53
Then it's not the answer.
– ffuentes
Mar 27 at 14:53
why can't be indexed ???? the indexes can be unique or not unique and in this case two not unique index can resolve the performace problem ..
– scaisEdge
Mar 27 at 14:53
why can't be indexed ???? the indexes can be unique or not unique and in this case two not unique index can resolve the performace problem ..
– scaisEdge
Mar 27 at 14:53
The index can be or uniqie or not unique ... the unioque is just a constrain for an index ..as you can see in mysql doc dev.mysql.com/doc/refman/8.0/en/create-index.html unique is an option ..
– scaisEdge
Mar 27 at 14:55
The index can be or uniqie or not unique ... the unioque is just a constrain for an index ..as you can see in mysql doc dev.mysql.com/doc/refman/8.0/en/create-index.html unique is an option ..
– scaisEdge
Mar 27 at 14:55
So I'll try it and I'll tell you how it went...
– ffuentes
Mar 27 at 14:56
So I'll try it and I'll tell you how it went...
– ffuentes
Mar 27 at 14:56
answer updated .. with index create commands
– scaisEdge
Mar 27 at 14:58
answer updated .. with index create commands
– scaisEdge
Mar 27 at 14:58
|
show 7 more comments
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55379936%2fis-there-a-way-to-optimize-this-query-join-with-several-rows-in-mysql%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
is
d.serialunique ?– Cid
Mar 27 at 14:45
No, it's not. It can show up in several ids.
– ffuentes
Mar 27 at 14:46
What about
p.serial? is it unique ?– Cid
Mar 27 at 14:47
No it's not. That table tracks the status of a device in a location and actually they repeat a lot.
– ffuentes
Mar 27 at 14:50