Is there a way to make Magento indexing more intelligent? - magento

I would like like to know if it is possible to make a new method to only update indexes on products which have changed since I run a store with 206000 records in the core_url_rewrite table and need to update product status everyday.
It takes 8 hours using a CLI call to index.php --reindex catalog_url.

Listen for the catalog_product_save_after event and update individual rows as they need updating, that way you won't have to perform full indexing everyday. Actually this is what's supposed to already happen so think, what are you doing that breaks this?

Related

magento 1.9 going very slow after create new category

I have created a new category on my store after creating this website taking 15-20 seconds to load, but before that it's taking only 5-6 seconds
Please re-index all the index and if it is still slow you can try by using flat tables for catalog.
Also make sure you have not added anything wrong in category details like special characters in desc etc.

Algolia Update Index On Relational Database change with Laravel Scout

I have implemented Aloglia for my Movies table with actors as relational table and it works fine.
Problem:
When I update any movie its also updating algolia index (its good). But how can I update index if I made any change in relational table (for example update an actor of movie).
How to push a specific record manually with laravel scout.
Thanks
The issue itself lies in laravel's events. Whats happening is scout is listening for an 'updated' event which only occurs in laravel when the model object is saved and is dirty (aka value differ from that in the db).
There are two ways you can do this.
The bad lazy way would simply be to add ->touch() to the model prior to save - this will force the updated_at field to update and ultimately trigger the updated event. This is bad as you're wasting a DB query.
The second and preferable way is to register another observer on 'saved' which triggers regardless of whether or not the object is dirty. Likely you either want to check if the model is dirty and only index when its not (to prevent double indexing from the updated event) or just de-register the 'updated' listener that comes in Scout.

How to perform recaching using memcached?

I am using memcached to cache a table records. My code is as follows
Rails.cache.fetch('custom_profiles') do
#custom_profiles=CustomProfile.where(:status=>"Active")
end
But whenever a new record has been added , its not getting updated.I want to update this variable whenever the table got edited. If you have any idea about this please share with me.
You can delete an item from cache like this
Rails.cache.delete('custom_profiles')
You might want to do this in some callbacks or Observers

mutual exclusion in joomla

I created an extension for joomla using:
$id=$database->insertid();
I just covered that if two users are logged on to the site will fit together perform two records in the database and then this statement will return in both cases the same value.
in php you can solve this problem with the transactions.
In joomla how do I solve this problem?
If you have a table you are working with that extends JTable then make sure that you included the check out functionality that is optionally a part of that. THis must means adding a couple of fields like what is in the content table. This will prevent two people from editing the same row at the same time which creates a race condition in which one of the other will lose their data.
Please note that both php and joomla functions to return the last insert id rely on the mysql implementation, and mysql returns the last id inserted on the currently open connection so concurrency is not an issue
#iacoposk8 Your are right it might possible that in very rear case. Such time try to add current logged in user id in your sql query or any where so that it doesn't make any confict. I hope you get it what i want to say. Thanks

What's the point of the cataloginventory_stock_status_idx table?

I have tried really hard to understand the cataloginventory_stock relations - I do know that both the stock_item as well as stock_status tables get updated when a stock item gets modified, but I wasn't able to figure out whether the stock_status_idx table is really required.
From what I can see, the stock_status_idx table contains the same information as the stock_status table. Is it a temporary table only? I did not see any problems with wrong stock status if I manually updated the stock_item and stock_status tables, but did not update the stock_status_idx table.
The thing is.. I thought it's somehow used for caching/the indexer. However, even if I didn't modify the stock_status_idx table, the stock status displayed just fine in the backend and in the frontend.
So, what's the point of the stock_status_idx table?
Thanks so much for your help.
I was wondering the same question and decided to dig as I could not find an answer anywhere.
It seems like the _tmp and _idx are used as temp holders for your indexed data.
For example, you can look at the reindexAll() method in app/code/core/Mage/Catalog/Model/Resource/Category/Indexer/Product.php and you will understand that it is using _idx tables to temporarily store it's data when generating the indexes:
$this->useIdxTable(true);
...
$idxTable = $this->getIdxTable();
....
$query = $select->insertFromSelect($idxTable, ...
At the end of the same method you will notice a nice $this->syncData() method call. You probably guessed it! The function lives in app/code/core/Mage/Index/Model/Resource/Abstract.php and is doing just that, syncs the _idx with main:
$this->_getWriteAdapter()->delete($this->getMainTable());
$this->insertFromTable($this->getIdxTable(), $this->getMainTable(), false);
$this->commit();
Best of luck!
idx table is used only when Magento need select many products based on their stock item, so the index on these tables are faster than use the main inventory tables.
I recommend you to write your data onto this table too. Or better, use Magento API or Magento App over PHP to write into Magento Database, is much more safe.
I looked into this for the same reason (to update stock quantities directly in Mysql) and will use the built in indexer feature of Magento with the "cataloginventory_stock" . I like this feature since it only takes a few seconds to run on my server.
you can reach the magento indexer and get some nice information
/[your store home]/shell then run: /usr/bin/php -f indexer.php info
here is the crontab line for running just the catalog inventory re-index:
30 3 * * * /usr/bin/php -f /home/client/www/shell/indexer.php -- --reindex cataloginventory_stock

Resources