Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
  #1  
Old 08-15-2011, 10:37 AM
DNCL DNCL is offline
 
Join Date: Jul 2011
Posts: 66
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Using indexes to speed up queries

Hello, i want to use indexes in mysql tables to speed up queries, can you give me the exact command to execute?


EDIT: found a command like this CREATE INDEX pagetext ON vb_post (pagetext);
but when i execute it i get the following error:
#1170 - BLOB/TEXT column 'pagetext' used in key specification without a key length
This is happening only in pagetext field in the whole table, other fields can be indexed, how do i fix this?

any help is appreciated
Reply With Quote
  #2  
Old 08-15-2011, 11:40 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Like the error says, if you index a BLOB or TEXT column, you need to specify a prefix length, like CREATE INDEX pagetext ON vb_post (pagetext(N)) (and of course it will only use the first N chars of the field in the index).

You may be interested in reading this: http://dev.mysql.com/doc/refman/5.0/...n-indexes.html
Reply With Quote
  #3  
Old 08-15-2011, 12:12 PM
DNCL DNCL is offline
 
Join Date: Jul 2011
Posts: 66
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can call me MySQL noob, i just want tp speed up queries by using indexes, can you give me a proper command to index the pagetext field for example please

EDIT: if i apply the command you gave me i get:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'N))' at line 1
Reply With Quote
  #4  
Old 08-15-2011, 12:32 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You need to change N to a number - the number of characters that you want to be indexed. Sorry, I don't know how that number should be chosen. I'm not a MySQL expert or anything, I just thought I could help you with the syntax for that command.

Did you read the manual pages that I linked to? It's really just one or a few paragraphs for each of 4 sections that talk about indexes.

BTW, I'm not sure indexing on pagetext will help you at all. It could only have a chance of speeding things up if there was a query being done with a WHERE clause using that column (or maybe an ORDER BY or GROUP or something like that), and there probably isn't. Like I said, I'm not a database expert or anything, but I think blindly creating an index for every column might not be a good idea, since many of them probably won't be used but they all have to be maintained any time the table is changed. What you can do is, if you think a specific page is slow you can use debug mode to display all the queries being done by that page, then see if any are taking an unusually long time, then see if there's something to be done to speed it up.
Reply With Quote
  #5  
Old 08-15-2011, 12:45 PM
DNCL DNCL is offline
 
Join Date: Jul 2011
Posts: 66
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for your help, when i run one of the sql tuners via shell i get in red text

You have a high ratio of sequential access requests to SELECTs
You may benefit from raising read_buffer_size and/or improving your use of indexes.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:43 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04087 seconds
  • Memory Usage 2,188KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete