I am working on task which require me to compare every column of Row. There are a number of ways to achieve, I am curious because number of rows is a big number. So here I am explaining it by example.
---------------------------------------------------------------------
ID[P_K] | Name | Address | City | Gender | College
---------------------------------------------------------------------
So above is a basic example of a table, which is hold data of Students from multiple colleges, now I am getting some data from outside source and need to compare it with data in my DB. Below are the possible ways to do it.
I will do select query with
where Id = <id>
and match it one by one in my code.Other way I can do a select query with
where ID = <id> and name = <name> and so on...
So now my preference is 2nd option, because of lesser complexity.
Now to go ahead there is only thing which is creating conflict in my mind.
Question:
Complexity of query these two queries comparing to each other(considering ID as Primary Key) :
where Id = <id>
where ID = <id> and name = <name> and so on...
I know this total depends on the MySQL algorithm, I've searched lot didn't find Select algorithm of MySql.
It will be helpful if someone can share Select algorithm.
Specific to Algorithm:
There are two ways this algorithm could work:
For number of rows { if(whereCondition1 && whereCondition2 .... && whereCondition<N>)}
}for number of rows { if(whereCondition1){ //Result filter according whereCondition1 if(whereCondition2){ //Result filter according whereCondition2 . . and so on... } else { continue; } } else { continue; } }
Now complexity for first one will be O(n). For second assuming ID[P_K], complexity will be reduced. Right?
So from above which algorithm is user? or non of these?