CCK Type is used in a view filter in the facebook_status table, but database row is of type text. This is generally a bad idea. Please change your view(s) to not filter on text or set the max length value in the CCK field to less then 255. facebook_status, facebook_status_recent
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | dbtuner-973380-10-01.patch | 7.92 KB | gapple |
| #10 | dbtuner-973380-10-02.patch | 2.03 KB | gapple |
| #5 | 973380-temp_obj_monthly.png | 39.8 KB | gapple |
| #5 | 973380-temp_obj_yearly.png | 30.11 KB | gapple |
Comments
Comment #1
icecreamyou commentedFBSS has absolutely nothing to do with CCK. DB Tuner is detecting something wrong.
The filter on the text columns in the facebook_status and facebook_status_recent views is
{facebook_status}.status <> ''which is fast.Comment #2
mikeytown2 commentedCould that view be configurable to filter the status text to something other then
''?Anyway there is a bug in db tuner as I assume most things used in views are CCK fields. Also need a way to disable the warning if the field is not a CCK field. But I would like to warn the admin about a view doing a text search as this is usually killer to your SQL server.
First thing to do is fix the wording so it doesn't say CCK if it's not a CCK table. Second thing is to find the longest value in the text field and see if it would fit in the table as an index. Example code for finding the biggest variable:
OR
OR ... (need to profile this on a big database (million + rows) and make sure it won't kill it)
If it would fit then recommend looking into adding an index. Do not allow this to be done from the GUI as this alters the DB without the module that created that table knowing about the new limit on that field.
Comment #3
icecreamyou commentedEvery view is configurable... the particular filter that is used in this case is exactly the correct one for the intended use case though. In English, the filter represents the argument "don't show blank status updates."
Comment #4
mikeytown2 commenteddup found #977672: Convert TEXT columns to VARCHAR if possible
Comment #5
gappleMy comment from #977672: Convert TEXT columns to VARCHAR if possible:
I created a separate issue since this one seemed to be focused on Views queries and column indexes, whereas I propose analyzing all TEXT columns for potential conversion, but they can be reasonably addressed together.
----
I've attached a couple of resource graphs showing temporary table usage on my server. One of the Drupal sites on the machine (the largest and busiest of 4) was modified to use VARCHAR columns where possible. The change in disk tables is most noticeable in the yearly graph, but apparent in the monthly graph as well. Previously it was consistently 30 - 35% of temp tables created on disk, with the current value approximately 8%.
Comment #6
mikeytown2 commentedMySQL 5.0.3 and up does support varchar lengths up to 65,535 bytes. Do a quick db_version check and go from there.
Comment #7
mikeytown2 commentedhappy with
Or this
did 2 Million small text rows in 30 seconds (term_data - description); tried to do 500K rows of 8GB of text (node_revisions - body), gave up on that. So queries like this are dependent on the size of the table. I think I will limit this to 96MB (configurable); any table above this size will not be scanned for the largest row.
Table: term_data Column: description
MyISAM - TEXT: 24 Seconds
MyISAM - VARCHAR: 3 Seconds
InnoDB - VARCHAR: 15 Seconds
InnoDB - VARCHAR & index: 5 Seconds
InnoDB - TEXT: 31 Seconds
This is my home computer (xampp on xp) so InnoDB is not tuned at all. Switching the database structures around took a very long time to do (hours per operation).
This is getting complicated so it sounds like I need to create a new menu entry for operations of this nature. Would be good because I can then issue more warnings about this eating your homework.
Comment #8
gappleI finally wrote a blog post about my experience converting TEXT columns: http://goldapplesoftware.ca/blog/2011-05/reducing-drupals-disk-temporary...
One of the things I found was that it is possibly to find all TEXT columns in the database using the following query:
The easiest way to check the size of entries in a text in the column is:
CHAR_LENGTH() should be used instead of LENGTH(), since UTF-8 will require CHAR_LENGTH() * 2 bytes be available for storage.
LENGTH() will return the number of bytes used for storage, and for UTF-8 will be anywhere between CHAR_LENGTH() and CHAR_LENGTH() * 2, since we don't know how many characters will use one or two bytes.
Comment #9
gappleI think the easiest recommendation to start with is to to set any CCK text fields to a maximum size <= 255 if possible.
Then, if any CCK fields have a a maximum size between 256 and approximately 30 000, we can suggest changing the database storage type to VARCHAR. (UTF-8 requires that two bytes of storage be available for every character. With the maximum row size being 64KiB,
64 * 1024 / 2 - [storage size of other columns]characters can be stored in a single column). A warning should be generated if the VARCHAR column's size is smaller than the field's maximum length, as it could result in data loss.If the CCK field is set to store multiple values or is connected to multiple content types it will be stored in a separate table and row size limits should be less of an issue. If the text field is single-valued and connected to only one content type though, other fields will definitely need to be taken into consideration.
----
Recommending converting other columns will require an analysis of the current data stored in the field, and if a suitable benefit could be realized. While more work, I think maintaining a list of columns suitable for optimization should be created rather than just doing a check on the maximum length of all columns and doing a generic recommendation.
The size of the data column for filefield/imagefield and the attributes column for link is dependent on the field's configuration. The deployment I checked doesn't seem to really use these fields, so their content is very short. I would like to see some more information from other people before attempting a recommendation here.
Comment #10
gappleHere's a couple patches for some conversion recommendations (the second patch builds off the first)
The first patch checks all CCK Text fields for the potential to be converted to VARCHAR, and makes recommendations based on the fields maximum length setting and the largest value currently stored in the field.
If the column is already converted to a VARCHAR it will perform some sanity checks to make sure that data will not be cut off when inserted, or that the column is not needlessly larger than the field's maximum length.
The second patch makes recommendations on converting the term_data.description column if it doesn't contain too large a value.
If the column is already a VARCHAR, it will check that the largest stored value is not close to the column's size, since the taxonomy module will not limit the length a user enters.
Comment #11
hefox commentedreturn $output ? $output : t('No Recommendations').
(at least put t around no recs).
Should this be a more generalized function? e.g. db_tuner_min_dbversion('5.0'3)?
Not sure if $table or column really needs to be treated like considering they're not user import (right?).
Improper t, can't be parsed like that.
return $output ? $output : t('No Recommendations').
(at least put t around no recs).
Should this be a more generalized function? e.g. db_tuner_min_dbversion('5.0'3)?
Not sure if $table or column really needs to be treated like considering they're not user import (right?).
Haven't tested patch yet. Might as well combine the two since one relies on other to apply properly.