g2_CacheMap table (too big)

marco963

Joined: 2006-11-12
Posts: 7
Posted: Tue, 2006-11-28 07:29

I am experiencing problems with the g2_CacheMap table; its size is increasing day after day and the web provider fixed a size limit I must fulfill.
I have read on previous posts that the problem is due to "optimization strategies", so I have disabled every kind of optimization.
My problem now is: can I drop the table to free precious space on my DB ?
I am not a SQL expert and I am not sure about it.

Can someone please help me ?

Best regards,
Marco Brivio


Gallery version = 2.1.2 core 1.1.0.2
PHP version = 4.4.4 cgi
Webserver = Apache/2.0
Database = mysql 4.0.27-standard-log, lock.system=flock
Toolkits = Exif, Getid3, NetPBM, SquareThumb, Thumbnail, Gd
Acceleration = partial/900, partial/900
Operating system = Linux webx18.aruba.it 2.6.15.3-p16 #1 SMP Tue Feb 7 19:48:10 CET 2006 i686
Default theme = carbon
Locale = en_US
Browser = Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Tue, 2006-11-28 10:18

Sure. On Site Admin -> Performance click the "Clear Cached Pages" button and it will empty the table for you.

 
marco963

Joined: 2006-11-12
Posts: 7
Posted: Tue, 2006-11-28 10:36

Thanks so much Bharat, now everything is perfect !

I hope in future releases of Gallery to have a function according to which the Cache can be used up to a predetermined limit depending on DB constraints.
It is a pity I had to disable Database optimization !

Best regards,
Marco

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Wed, 2006-11-29 06:37

Great idea, Marco! We're doing a better job about this in 2.2, but it can still be improved. Would you file a feature request for this please? Thanks!

 
darkol

Joined: 2008-01-19
Posts: 11
Posted: Mon, 2009-05-04 13:36

Hello,
I have the same problem but I cant resolv it?!

My gallery is:

Gallery version = 2.2.3 core 1.2.0.5
PHP version = 5.2.9 cgi-fcgi
Webserver = Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8i DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
Database = mysqlt 5.0.75-community-log, lock.system=flock
Toolkits = ArchiveUpload, Exif, NetPBM, Gd, LinkItemToolkit, Getid3, Dcraw, SquareThumb, Thumbnail
Acceleration = none/900, none/900
Operating system = Linux host287.hostmonster.com 2.6.28-9.16.intel.BHsmp #1 SMP Sat Apr 18 11:41:59 MDT 2009 x86_64
Default theme = matrix
gettext = enabled
Locale = sr_YU
Browser = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10
Rows in GalleryAccessMap table = 518
Rows in GalleryAccessSubscriberMap table = 5011
Rows in GalleryUser table = 76
Rows in GalleryItem table = 5001
Rows in GalleryAlbumItem table = 245
Rows in GalleryCacheMap table = 0

When I try Site Admin -> Performance click the "Clear Cached Pages" - noting hapends!!!
Can I resolv this problem directli from the php msql admin? Can I delete some rovs or not in the table: g2_SessionMap ??
I am experiencing problems with the g2_CacheMap table; its size is increasing day after day and the web provider fixed a size limit I must fulfill.
My problem now is: can I drop the table to free precious space on my DB ?
I am not a SQL expert and I am not sure about it.

Thanks
Sincereli
darko l

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Tue, 2009-05-05 04:02

darko: you can do this to clean it out:

  mysql -u<user> -p<pass> -e "truncate g2_CacheMap" <dbname>

User your mysql username, password and database name. This is safe, you can run it as often as you want. When the cache is empty, your site will run a little bit slower (but it'll start filling up again with the most frequently visited stuff first).

 
darkol

Joined: 2008-01-19
Posts: 11
Posted: Wed, 2009-05-06 13:02

I am really sorry but I do not understand what you say to me?
How to do this from cpanel phpMyAdmin?

My problem is:

g2_SessionMap - 15 Mb

Thanks

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2009-05-06 15:07
Quote:
phpMyAdmin?

Easy - go to the table (make sure it's the *correct* table) and use the button marked "empty".

EDIT:

@bharat: Am I right in thinking that the cacheMap table isn't involved in the regular caching of db queries or entities, and that if you turn off all acceleration (site admin -> performance) then the cache-map table stays empty?

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Wed, 2009-05-06 15:58

@alecmyers yes. g2_CacheMap is for page and template caching; it can be emptied at any time. You can also empty the g2_SessionMap at any time too (but it'll log out everybody who's logged in, and if they're in the middle of some operation that operation will fail)

 
darkol

Joined: 2008-01-19
Posts: 11
Posted: Mon, 2009-05-11 14:59

Hello,
thanks for answer!

One more caustion please for you!?
When I backup mysql database (export), what I nead to chek in phpadmin?
I send you picture? Is it ok like in the photo, by default? Or I nead to change somting?

[img]http://www.artgalerija.net/backup.jpg[/img]

Thanks in advance

darko l

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2009-05-11 15:08

Backup directions:
http://codex.gallery2.org/Gallery2:How_To_Backup_and_Sync_the_DB

You can empty the g2_CacheMap and g2_SessionMap prior to backup so it is smaller and faster to perform.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
darkol

Joined: 2008-01-19
Posts: 11
Posted: Thu, 2009-11-26 18:53

www.artgalerija.net - My site has about 500 visitors per day, which opened around 6000 images, and make bandwidth of 1 Gb per day! And for 24 hours a table in the database g2_SessionMap to increase by 20 Mb. Is this normal and how to solve and not to empty the table every day? Because if I leave only 10 days a database site we grow to 300 MB and hosting companies will put out my site! And that I can not let that happen.

Please help to solve this problem!

Hello,
A second problem is my mistake that I always appear in error log:

Too many connections in /home2/uljenapl/public_html/artgalerija/lib/adodb/drivers/adodb-mysql.inc.php on line 366

* 1000 times

Thanks in advance
Darko Lazic

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Thu, 2009-11-26 19:06
Quote:
bandwidth of 1 Gb per day

Pay for better hosting, is my top suggestion. People tend to assume that Gallery2 will work on cheap hosting packages, which it will, but if you have a busy site then that might not suffice. Amazon.com doesn't run on a $5-per-month package, does it?

 
darkol

Joined: 2008-01-19
Posts: 11
Posted: Thu, 2009-11-26 19:36

Thank you for your reply,
but I do not see any connection is hosting this my problem?
So tell me how to solve the problem with a table that is a lot of increases and full without nead!

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Thu, 2009-11-26 19:41
Quote:
hosting companies will put out my site!

Cheap hosting.

Quote:
Too many connections in /home2/uljenapl/public_html/artgalerija/lib/adodb/drivers/adodb-mysql.inc.php on line 366

This too is cheap hosting. If you're running a very busy site, you need to pay $$$ for good hosting. You can't have it for free.

 
darkol

Joined: 2008-01-19
Posts: 11
Posted: Thu, 2009-11-26 19:58

Thank you for your reply

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Thu, 2009-11-26 20:16

You can delete any rows from the g2_SessionMap which are attached to guest users. On my production database, the session map looks like this:

mysql> select distinct g_userId, count(*) from g2_SessionMap group by g_userId;
+----------+----------+
| g_userId | count(*) |
+----------+----------+
|        5 |    68725 | 
|        6 |        1 | 
+----------+----------+

So in my case (and almost definitely in your case), the guest id is 5. You can run this SQL regularly:

DELETE FROM g2_SessionMap WHERE g_userId=5 AND (UNIX_TIMESTAMP() - g_modificationTimestamp) > 86400;

that'll delete any guest sessions that have been inactive for a day.

---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git

 
darkol

Joined: 2008-01-19
Posts: 11
Posted: Thu, 2009-11-26 20:41

Thank you very much you are great, fast and professional!

 
darkol

Joined: 2008-01-19
Posts: 11
Posted: Thu, 2009-11-26 21:07

Problem whit error log?!
Hello,
I have the problem whit error log.
Always:

Too many connections in /home2/uljenapl/public_html/artgalerija/lib/adodb/drivers/adodb-mysql.inc.php on line 366

this file is the problem: /lib/adodb/drivers/adodb-mysql.inc.php

And this mistake is repeated in the last time every few minutes!
What's the problem? Prior to this rarely occur, for example 2 years. But I then had fewer visits to the site about 100 to 200, and now have from 400 to 500 visitors on the site!
Does it have something to do or not? And how to solve this problem?

Thank you in advance
you are great

Darko Lazic
www.artgalerija.net

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2009-11-27 02:23
Quote:
What's the problem?

Your host has limited the number of connections to the DB as seen by this error:

Quote:
Too many connections

Quote:
And how to solve this problem?

Use less connections the DB ( less traffic to your site ) or ask you host how you can have the limit increased. If they say they can't you can move.
This might help:FAQ: I seem to be running into some sort of MySQL query limit, is there anything that can be done?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team