Advertisement:

Author Topic: Osclass Extreme Memory Usage with Multi-Country  (Read 6371 times)

Aficionado

  • Guest
Re: Osclass Extreme Memory Usage with Multi-Country
« Reply #15 on: September 05, 2015, 06:44:47 pm »
@Aficionado
I have checked your file and found that there is more queries running for long time (8 or more seconds), there is probably relation to city table in all of them. It is very strange.

And that is related to memory problems  ?


teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Osclass Extreme Memory Usage with Multi-Country
« Reply #16 on: September 05, 2015, 06:45:38 pm »
Hi,

@frosticek, those are exponential numbers (9.7036361694336E-5), in fact they are very small values.

This is what bothers me:

Code: [Select]
1.6615619659424
**************************************************
SELECT pk_i_id, fk_i_region_id, s_name, fk_c_country_code, b_active, s_slug
FROM (oc_t_city)
ORDER BY s_name ASC
--------------------------------------------------

What module would need to retrieve absolutely all the cities in your database in alphabetical order? ???

@Aficionado, have you tried using another theme?

Regards
« Last Edit: September 05, 2015, 06:48:49 pm by teseo »

Aficionado

  • Guest
Re: Osclass Extreme Memory Usage with Multi-Country
« Reply #17 on: September 05, 2015, 06:51:58 pm »


@Aficionado, have you tried using another theme?

Regards

Yes, Bender and Modern. Same problem. But OsclassWizards is based on Bender, so ... if Bender had this ....

I will spend this weekend to solve this, since i can't bear it anymore. If Osclass can't handle multi-countries then i will have to find something else for this case.


frosticek

  • Hero Member
  • *****
  • Posts: 3948
Re: Osclass Extreme Memory Usage with Multi-Country
« Reply #18 on: September 05, 2015, 07:14:09 pm »
@teseo
Ah yes I missed that.
I have same query on my theme, but with filter on region ID.

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Osclass Extreme Memory Usage with Multi-Country
« Reply #19 on: September 05, 2015, 08:06:27 pm »
...
« Last Edit: September 05, 2015, 08:26:07 pm by teseo »

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Osclass Extreme Memory Usage with Multi-Country
« Reply #20 on: September 05, 2015, 10:09:42 pm »
That query is produced by osc_get_cities() helper with no region parameter. Also, it might appear as City::newInstance()->listAll();

Now, in vanilla Bender is only used in user-profile.php, and even if the user still hasn't set any location it would retrieve only the cities of the 1st country in your database.

So, you must have something like that in a plugin or in some custom modification. ???

Regards

Aficionado

  • Guest
Re: Osclass Extreme Memory Usage with Multi-Country
« Reply #21 on: September 05, 2015, 10:29:17 pm »
That query is produced by osc_get_cities() helper with no region parameter. Also, it might appear as City::newInstance()->listAll();

Now, in vanilla Bender is only used in user-profile.php, and even if the user still hasn't set any location it would retrieve only the cities of the 1st country in your database.

So, you must have something like that in a plugin or in some custom modification. ???

Regards

I have no modifications related to that. But i have some plugins from Osclass team, like rich edit etc etc. I will disable everything and test with stock Bender and come back to post.

But i do remember same problems with Modern theme, still i will try again.


Aficionado

  • Guest
Re: Osclass Extreme Memory Usage with Multi-Country
« Reply #22 on: September 06, 2015, 01:57:15 am »
ok. some update on this for anyone who cares to read.

For some reason Bender i was testing was Bender 2.01 and i installed Bender 3x. With Bender 3 i see no memory errors with 256 mb.

So, without being 100% sure, i think it is theme related. I will do some more testing with other themes and see how it goes.

Editing an ad WITHIN admin/Listings there is no error whatever. So one more reason to see if it is theme related.

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Osclass Extreme Memory Usage with Multi-Country
« Reply #23 on: September 06, 2015, 02:21:11 am »
***CORRECTED AGAIN***

It's a theme issue. Just seen a reference to Osclasswizards on your queries log.

Locate this in item-post:

Code: [Select]
ItemForm::city_select(osc_get_cities(),osc_user());
an replace with:

Code: [Select]
ItemForm::city_select(osc_get_cities(osc_user_region_id()), osc_user());
That seems to be working all right with no loading of all cities anymore.

Regards
« Last Edit: September 06, 2015, 02:45:03 pm by teseo »

Aficionado

  • Guest
Re: Osclass Extreme Memory Usage with Multi-Country
« Reply #24 on: September 06, 2015, 02:43:01 am »
@Teseo

Dude i don't know HOW TO THANK YOU !!

THANKS !!!

That did solve the problem and also some strange timeouts when editing.

I will copy your fix to their forum.

Again, a big Thanks.


teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Osclass Extreme Memory Usage with Multi-Country
« Reply #25 on: September 06, 2015, 02:56:27 am »
...
« Last Edit: September 06, 2015, 02:43:24 pm by teseo »

Aficionado

  • Guest
Re: Osclass Extreme Memory Usage with Multi-Country
« Reply #26 on: September 06, 2015, 03:02:55 am »
@Teseo

Are the above fixes only for multi-countries ?


SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: Osclass Extreme Memory Usage with Multi-Country
« Reply #27 on: September 06, 2015, 03:09:44 am »
Nice find teseo! 8)

One question looking at the whole thread here, were ALL cities (from all countries) being loaded using that initial code??


Regards,
Eric

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: Osclass Extreme Memory Usage with Multi-Country
« Reply #28 on: September 06, 2015, 01:08:35 pm »
I was completely absent from the forums past few days and I missed this exciting discussion.
Although teseo already did a great job, I would just add a different approach for solution:

Code: [Select]
ItemForm::city_select(osc_get_cities(osc_user_region_id()), osc_user());

ItemForm class is still being used (instead of UserForm in teseo's solution) which keeps things as it should.

Regards
dev101

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Osclass Extreme Memory Usage with Multi-Country
« Reply #29 on: September 06, 2015, 02:42:22 pm »
Hi @dev101,

Yep, I was looking at the only use of osc_get_cities() -with no region parameter- in Bender vanilla, in user-profile.php and I used Userform:: inadvertedly, same result anyway.

Now I realize the solution you propose is what is recommended here:

https://doc.osclass.org/Changing_between_drop-down_and_autocomplete_for_locations

And seems good enough. If it's a non-logged user or a logged user with no location data in his/her profile yet, that would retrieve cities for the first country in the database.

My hack using that dummy array (1,2) intended to save time and skip population of a select that will be overriden later via Ajax call (once you expressly select a region), but seems you need something more there for the neutral option "Select a city" to be shown...

What is totally clear is that osc_get_cities() -with no region parameter- never should be used unless (as in the case on that user-profile.php) already a View variable "cities" has been created.

Thanks for your input, regards.
« Last Edit: September 06, 2015, 02:45:45 pm by teseo »