Hot File

Create Some SQL Query Optimization Technique

View: 267    Dowload: 0   Comment: 0   Post by: hanhga  
Author: none   Category: MySQL   Fields: Other

9 point/3 review File has been tested

It is very important to avoid unnecessary data selection of the query. We should select data field that we need but not all fields of the table.

Introduction

1. Selection of required field only.

It is very important to avoid unnecessary data selection of the query. We should select data field that we need but not all fields of the table.

 SELECT login_id, pawwsord FROM tbluser

2. Index

Properly created Indexes are help to optimize search result. You need to better understanding of the databases before selection of better performing index. Selection of highly utilized filed as index is very important.

 CREATE clustered INDEX ind_login_id ON tbluser(login_id)

3. Primary key

Primary key is the most important index of the table. Most important thing of the primary key is selection of short and unique field. This will leads to easy access to data records.

CREATE TABLE tbluser(id INT,
     name VARCHAR(150),
     email VARCHAR(100),
     login_id VARCHAR(100),
     password VARCHAR(10),
    primary_key(id)
     )

4. Index unique column

Indexing of unique column will improve searching and increase efficiency of the database. You must have better understanding of the data field and their utilization before indexing unique column. Indexing lower utilized column is not helping any improvement of the efficiency of the database.

CREATE INDEX ind_email ON tbluser(email)

5. Select limited records

None of the user interfaces can visualize thousand of record at ones. Hence no means of having selected all the record at once, so always limit the selection when you have large number of record set. Select required data only.

SELECT id, name, email, login_id,password FROM tbluser WHERE 1 limite 10

6. Selection of correct data type and length

Use most appropriate data type and correct length of the data. Bad selection data type will produce bulky databases and poor performance. This will improve resource utilization of the database server.

CREATE TABLE tbluser(id INT,
     name VARCHAR(150),
     email VARCHAR(100),
     login_id VARCHAR(100),
     password VARCHAR(10)
     )

 

7. Avoid in sub query

Always avoid use of IN sub query your application. In sub query will evaluate all the record of table A with table B (product of records) before selecting re

SELECT login_id,name, email FROM tbluser WHERE login_id IN ( SELECT login_id FROM tbllogin_details)

one of correct way is used inner join

SELECT login_id,name, email FROM tbluser INNER JOIN tbllogin_details ONtbluser.login_id = tbllogin_details.login_id

8. Avoid NOT operator

Please avoid the usage of NOT operator situation that numbers of qualifying records are lower than unqualified records. Always used positive operator such as LIKE, EXIST than NOT LIKE, NOT EXIST.

 SELECT * FROM tbluser WHERE email NOT LIKE '%gmail%'

The other way is

 SELECT * FROM tbluser WHERE email LIKE '%yahoo%'

Create Some SQL Query Optimization Technique

Create Some SQL Query Optimization Technique Posted on 07-01-2016  It is very important to avoid unnecessary data selection of the query. We should select data field that we need but not all fields of the table. 3/10 267

Comment:

To comment you must be logged in members.

Files with category

  • SQL Query to Find Nth Highest Salary of Employee with java

    View: 367    Download: 0   Comment: 0   Author: none  

    SQL Query to Find Nth Highest Salary of Employee with java

    Category: MySQL
    Fields: Other

    0/0 review
    This is a very common interview question if you are going for the role at junior level. Most of the people learn it character by character, but few understand how this query works.

  • World OOP With PHP and MySQL

    View: 1127    Download: 0   Comment: 0   Author: none  

    World OOP With PHP and MySQL

    Category: MySQL
    Fields: Other

    0.32142857142857/14 review
    Setting up the skeleton of our class is fairly simple once we figure out exactly what we need.

  • How to Build a Newsletter System With PHP and MySQL

    View: 1476    Download: 0   Comment: 0   Author: none  

    How to Build a Newsletter System With PHP and MySQL

    Category: MySQL
    Fields: Other

    1.125/4 review
    When starting any project, I like to layout the folders before I start coding, so lets do that now.

  • Top 20+ MySQL Best Practices that can not be ignored

    View: 1064    Download: 0   Comment: 0   Author: none  

    Top 20+ MySQL Best Practices that can not be ignored

    Category: MySQL
    Fields: Other

    1.6666666666667/3 review
    Database operations often tend to be the main bottleneck for most web applications today.

  • Create a PHP/MySQL Powered Forum from Scratch

    View: 1295    Download: 0   Comment: 0   Author: none  

    Create a PHP/MySQL Powered Forum from Scratch

    Category: MySQL
    Fields: Other

    1.5/3 review
    In this tutorial, we're going to build a PHP/MySQL powered forum from scratch.

  • Triggers Introduction to MySQL

    View: 385    Download: 0   Comment: 0   Author: none  

    Triggers Introduction to MySQL

    Category: MySQL
    Fields: Other

    1.6666666666667/3 review
    I would guess, even armed with this knowledge, that a good many of you are not taking advantage of triggers with MySQL.

  • How to Stored Procedures in MySQL 5

    View: 384    Download: 0   Comment: 0   Author: none  

    How to Stored Procedures in MySQL 5

    Category: MySQL
    Fields: Other

    2.25/2 review
    MySQL 5 introduced a plethora of new features - stored procedures being one of the most significant. In this tutorial, we will focus on what they are, and how they can make your life easier.

  • The strength of the PDO and. MySQLi: Which Should You Use?

    View: 395    Download: 0   Comment: 0   Author: none  

    The strength of the PDO and. MySQLi: Which Should You Use?

    Category: MySQL
    Fields: Other

    1.5/3 review
    When accessing a database in PHP, we have two choices: MySQLi and PDO. So what should you know before choosing one?

 
Newsletter Email

File suggestion for you

File top downloads

logo codetitle
Codetitle.com - library source code to share, download the file to the community
Copyright © 2015. All rights reserved. codetitle.com Develope by Vinagon .Ltd