Results 1 to 10 of 10
  1. #1

    Default multiple index (sql)


    mangutana lang ko ba. 16 rajud na kutob ang pwede ma index sa sql? and why 16 ra?

    lain sad ni nga question.

    sample naa tai table with the ff. fields
    -id
    -firstname
    -lastname
    -MI
    -address

    nya naka index ang firstname ug lastname (flindex). now i try sa phpmyadmin pa run ani nga select nga statement.

    SELECT firstname,lastname FROM `record_table` use index(flindex)

    ang mugawas is ang sorted nga firstname ug lastnames.(which is what I want)

    pero if kani nga select statement

    SELECT firstname,lastname, MI FROM `record_table` use index(flindex)

    dili na siya sorted. ing ana jud na sya? kung kailangan nako i sort tanan records nako kailangan apil sa ako i multiple index ang tanan fields? what if more than 16 ang columns sa table?
    unsai lain way para ma sort siya?


    thank you.

  2. #2
    kung kailangan nako i sort tanan records nako kailangan apil sa ako i multiple index ang tanan fields? what if more than 16 ang columns sa table?
    unsai lain way para ma sort siya?
    SELECT firstname,lastname, MI FROM `record_table` ORDER BY firstname ASC, lastname ASC

    no need man tali i.index tanan fields.. i.index lang ang fields nga daghan different records
    kay ang primary key automatic naman na nga index tali, i'm not sure...
    ako nasabtan sa index makatabang sa performance kung magsearch ka
    mura sa library ba..

    ....

  3. #3
    the primary purpose of sql index is performance...if you want to sort your requested data use ORDER BY

  4. #4
    ahahaha....ka simang dia ani ako question oi.karun rako ka realize, after na na solve...hahah.... I did what rhex_tendo suggested thank you ^^

  5. #5
    Quote Originally Posted by c-chan View Post
    ahahaha....ka simang dia ani ako question oi.karun rako ka realize, after na na solve...hahah.... I did what rhex_tendo suggested thank you ^^
    Don't forget to use LIMIT sytax:
    Code:
    SELECT ...
    FROM  ...
    ORDER BY ...
    LIMIT 16
    for specific records selection... extend the syntax of LIMIT
    Code:
    SELECT ...
    FROM  ...
    ORDER BY ...
    LIMIT 0, 16
    LIMIT 16, 16
    LIMIT 32, 16
    LIMIT 48, 16
    and so on...

  6. #6
    Quote Originally Posted by dodie View Post
    Don't forget to use LIMIT sytax:
    Code:
    SELECT ...
    FROM  ...
    ORDER BY ...
    LIMIT 16
    for specific records selection... extend the syntax of LIMIT
    Code:
    SELECT ...
    FROM  ...
    ORDER BY ...
    LIMIT 0, 16
    LIMIT 16, 16
    LIMIT 32, 16
    LIMIT 48, 16
    and so on...
    pagination on the works...

  7. #7
    Quote Originally Posted by salbahis View Post
    pagination on the works...
    Pagination algorithm. hahahaha oh yeah.
    Mao ni formula ..........
    Code:
          ($pageinput -1) * $rows
    Last edited by dodie; 01-05-2011 at 03:22 PM.

  8. #8
    Quote Originally Posted by dodie View Post
    Pagination algorithm. hahahaha oh yeah.
    Mao ni formula ..........
    Code:
          ($pageinput -1) * $rows

    hehehe we have a similar algo....

    and also... it also help to have one field nga unique to avoid duplication....

  9. #9

  10. #10
    take note lang nga dili maayo ug taas kaayo ang size sa imo index kay grabi kaayo ang I/O contention ana during insert, update, ug delete.

    Apply index only to the column use in where clause, join operation.

    Okay ra na ang taas imo size sa index ug ang imo database is used for reporting. pero ug OLTP gani patay gyud ang performance sa imo database server kay grabi ang I/O contention.

    Makatabang ni ang index sa performance sa query pero kadto ra pud necessary columns nga kinahanglan buhatan ug index. Kay daghanon gani nimo bisan katong dili na kinahanglan basin problema na nuon sa query performance imo ma encounter imbes nga makatabang. Take note sad nga ang index mo take na siya ug additional disk space sa imo storage maong kinahanglan gyud nga kato ra kinahanglan ang buhatan ug index.


    Naay mga database nga para ra gyud sa reporting iya purpose mao ni sila ng pwede ra daghanon ang index. dili siya problema kay usually ang update ani nga database kay gi schedule ra man (e.g. every 12 mid night).

  11.    Advertisement

Similar Threads

 
  1. SQL 101
    By BadDudes in forum Programming
    Replies: 44
    Last Post: 08-31-2012, 07:34 AM
  2. SQL: Using LIKE statement on a clustered Index
    By silent-kill in forum Programming
    Replies: 13
    Last Post: 05-16-2008, 09:15 AM
  3. SQL Quiz!
    By maldito_guapito in forum Programming
    Replies: 45
    Last Post: 01-24-2006, 01:01 PM
  4. wat's d best sql back-end?
    By edshark in forum Software & Games (Old)
    Replies: 5
    Last Post: 09-15-2005, 04:41 PM
  5. HOW TO CONNECT SQL SERVER USING SQL AUTHENTICATION
    By edshark in forum Software & Games (Old)
    Replies: 13
    Last Post: 09-02-2005, 04:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top