Query is faster with additional JOIN Announcing the arrival of Valued Associate #679: Cesar...
Why don't the Weasley twins use magic outside of school if the Trace can only find the location of spells cast?
How does modal jazz use chord progressions?
How do you clear the ApexPages.getMessages() collection in a test?
Who can trigger ship-wide alerts in Star Trek?
Why is "Captain Marvel" translated as male in Portugal?
Working around an AWS network ACL rule limit
How many things? AとBがふたつ
How to say that you spent the night with someone, you were only sleeping and nothing else?
Active filter with series inductor and resistor - do these exist?
What did Darwin mean by 'squib' here?
No baking right
What was the last x86 CPU that did not have the x87 floating-point unit built in?
Biased dice probability question
When communicating altitude with a '9' in it, should it be pronounced "nine hundred" or "niner hundred"?
What do you call the holes in a flute?
Estimate capacitor parameters
90's book, teen horror
Why is there no army of Iron-Mans in the MCU?
Can I add database to AWS RDS MySQL without creating new instance?
What's the point in a preamp?
What do I do if technical issues prevent me from filing my return on time?
Simulating Exploding Dice
What is the electric potential inside a point charge?
What is the order of Mitzvot in Rambam's Sefer Hamitzvot?
Query is faster with additional JOIN
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)SQL Server Join/where processing orderWhy do aggregate functions alter the way my rows are fetched?Are JOINs on non-indexed columns faster than sub-queries?Optimizing multi-table left joinsShould I use left join to do my job in this scenario?MySQL: Why queries with subqueries are much faster than single query?How to improve query count execution with mySql replicate?How does LEFT JOIN with WHERE clause works?Which Query of JOIN with DISTINCT & JOIN with Subquery has better Performance?Counting unique (distinct) users per day
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
SELECT COUNT(DISTINCT User_id) FROM Session
GROUP BY Floor_id;
SELECT COUNT(DISTINCT User_id) FROM Session
JOIN Floor ON Floor.id = Floor_id
GROUP BY Floor_id;
The second query runs 20x faster than the first query.
Floor_id
is a FK to Floor.id
.
Why is this the case and how should we know when we can make use of JOINs to speed up queries?
mysql join mysql-5.7 count
add a comment |
SELECT COUNT(DISTINCT User_id) FROM Session
GROUP BY Floor_id;
SELECT COUNT(DISTINCT User_id) FROM Session
JOIN Floor ON Floor.id = Floor_id
GROUP BY Floor_id;
The second query runs 20x faster than the first query.
Floor_id
is a FK to Floor.id
.
Why is this the case and how should we know when we can make use of JOINs to speed up queries?
mysql join mysql-5.7 count
add a comment |
SELECT COUNT(DISTINCT User_id) FROM Session
GROUP BY Floor_id;
SELECT COUNT(DISTINCT User_id) FROM Session
JOIN Floor ON Floor.id = Floor_id
GROUP BY Floor_id;
The second query runs 20x faster than the first query.
Floor_id
is a FK to Floor.id
.
Why is this the case and how should we know when we can make use of JOINs to speed up queries?
mysql join mysql-5.7 count
SELECT COUNT(DISTINCT User_id) FROM Session
GROUP BY Floor_id;
SELECT COUNT(DISTINCT User_id) FROM Session
JOIN Floor ON Floor.id = Floor_id
GROUP BY Floor_id;
The second query runs 20x faster than the first query.
Floor_id
is a FK to Floor.id
.
Why is this the case and how should we know when we can make use of JOINs to speed up queries?
mysql join mysql-5.7 count
mysql join mysql-5.7 count
asked 3 mins ago
Avery235Avery235
1164
1164
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "182"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2fdba.stackexchange.com%2fquestions%2f234788%2fquery-is-faster-with-additional-join%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Database Administrators Stack Exchange!
- 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%2fdba.stackexchange.com%2fquestions%2f234788%2fquery-is-faster-with-additional-join%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