1

Maybe it sound's like i'm an idiot... But i'm developing app with huge db on RoR. Also i see that if i do some query and after that do it one more it is doing much faster, becouse it has been cached... But could i send all my table data to cache via some query, to improve speed, so that simple my table will be in ram memory? I read a lot about encreasing cahce size etc... But how can i send this all data in cache not when user do some query (if so user see data from cache)...

*************************** 1. row ***************************
       Table: ART_LOOKUP
Create Table: CREATE TABLE `ART_LOOKUP` (
  `ARL_ART_ID` int(11) NOT NULL,
  `ARL_SEARCH_NUMBER` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `ARL_KIND` int(3) DEFAULT NULL,
  `ARL_BRA_ID` int(11) DEFAULT NULL,
  `ARL_DISPLAY_NR` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `ARL_DISPLAY` int(11) DEFAULT NULL,
  `ARL_BLOCK` int(11) DEFAULT NULL,
  `ARL_SORT` int(11) DEFAULT NULL,
  KEY `ARL_ART_ID` (`ARL_ART_ID`),
  FULLTEXT KEY `ARL_SEARCH_NUMBER` (`ARL_SEARCH_NUMBER`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
1 row in set (0.00 sec)



*************************** 1. row ***************************
       Table: ARTICLES
Create Table: CREATE TABLE `ARTICLES` (
  `ART_ID` int(11) NOT NULL,
  `ART_ARTICLE_NR` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
  `ART_SUP_ID` int(11) DEFAULT NULL,
  `ART_DES_ID` int(11) DEFAULT NULL,
  `ART_COMPLETE_DES_ID` int(11) DEFAULT NULL,
  `ART_CTM` blob,
  `ART_PACK_SELFSERVICE` int(11) DEFAULT NULL,
  `ART_MATERIAL_MARK` int(11) DEFAULT NULL,
  `ART_REPLACEMENT` int(11) DEFAULT NULL,
  `ART_ACCESSORY` int(11) DEFAULT NULL,
  `ART_BATCH_SIZE1` int(11) DEFAULT NULL,
  `ART_BATCH_SIZE2` int(11) DEFAULT NULL,
  `Quantity` int(5) DEFAULT NULL,
  `Price` float DEFAULT NULL,
  `Waittime` int(3) NOT NULL,
  `datetime_of_update` datetime DEFAULT NULL,
  KEY `ART_ID` (`ART_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

via privacy can't show all

PavelBY
  • 193
  • 2
  • 8
  • 1
    Let the MySQL engine handle that. Increase memory buffers (how much RAM does the systme have? how much can it be given to the mysql service?). But the MySQL server cached image of a table or query will have to be altered or reloaded when the (underlying) tables change (with an insert, delete or update), right? – ypercubeᵀᴹ Nov 16 '12 at 11:38
  • If the memory that mysql uses is large enough to hold the whole database and your tables are not written often, it will be using both the tables loaded in memory and cached queries. – ypercubeᵀᴹ Nov 16 '12 at 11:42
  • @ypercube yes right, if new data inserted cache image must be reloaded... For example all db have about 10gb and i have 16gb of ram. Only two tables of this db are often changing, but there are using less then 50mb... It's a catalog, so all catalog tables i wanna to be cachedm and also this two tables (there are changing one time in a day) – PavelBY Nov 16 '12 at 12:04
  • Sometimes people put memcached in front of DB to do what you described. It can lead to real performance increase if you can leverage specific knowledge in your application's access pattern. The cache-money gem integrates with ActiveRecord easily. – kizzx2 Nov 16 '12 at 14:26
  • @kizzx2 maybe no... need just mysql – PavelBY Nov 16 '12 at 14:48
  • becouse than i will ned to convert mysql to memcached – PavelBY Nov 16 '12 at 14:48
  • also if vpn will be another not with 16gb ram this will be dangerous – PavelBY Nov 16 '12 at 14:48
  • What storage engine are the tables using (all InnoDB,all MySAM, or a mizture of both)? 2) Are there any specific tables you want cached? Please run SHOW CREATE TABLE tablename\G for each table and post them in the question. 3) Please post important queries in the question.
  • – RolandoMySQLDBA Nov 16 '12 at 15:09
  • @RolandoMySQLDBA queries are to huge, but also via privacy i can't post them... Both: innodb and myisam. There are specific tables i wanna be cached, also main tabledata: added in q – PavelBY Nov 16 '12 at 15:31
  • If the queries are "huge", then they sound inefficient. Are there multiple JOINs? Do you need new indexes? Give 10% of available memory to key_buffer_size and 35% to innodb_buffer_pool_size and no more than 50M to query_cache_size. – Rick James Nov 20 '12 at 02:23