money in sql (mssm) - language-agnostic

I want to delete the third zero after the point in MSSM

so do it, nobody is going to stop you;)
note: you should describe problem, provide us with your solution which does not work, or something liek this. Be more exact

Related

Magento sort products in category by pageviews

I would like to sort products in category by popularity(popularity means pageviews). To realize this I created an attribute(page_view) which I increment on product details page and use this attribute to sort products in category. Everything works ok in terms of functionality but from performance point of view it is not a solution as because of increment and save product cost too much. It took around 5 second to load product details page while without it is around 0.9s. I tried to place this increment atribute code very deep system but it kill performance anyway. Does anyone have such problems? And maybe have some suggestions how to realize such things. Thank you in advance. Any technical deep explanations how/why it happens is very welcome. I know that it is atribute and $product->save(); affect a lot of products but anyway can't explain why so much.
You should be sure your attribute is part of the catalog_product flat table so you don't need to join to the EAV-tables to do that sort operation.
unfortunately I am going to answer socond time to my own question after finding the answer by myself, hope this will help someone sometime. The problem is that $product->save() is evil. It is very slow operation as it update a big amount of tables and this why it took several seconds. Instead of this I used saveAttribure() function which seems to be faster as it do less job on background. So remamber that "save" function of product is evil.

Is there any way to tell how long a MySQL query will take to run?

Other than running it to completion...
Is there some sort of progress you can monitor to see what operations are happening as your query is being processed that would give you a sense of how long it's going to take, or at least what step it is on, what steps have happened, and which remain?
If yes, would this same tool help you identify the part of your query that is taking the longest?
I'm trying to get a better sense for what makes some queries take longer than others.
It's called profiling : http://dev.mysql.com/tech-resources/articles/using-new-query-profiler.html
MySQL has one built-in for you. : )
You can use explain to ask MySQL to show you why a function takes as longs as it does.
http://dev.mysql.com/doc/refman/5.0/en/explain.html
The idea is that it'll show you things like which indexes it uses, etc, which will help you to then optimise either the query or the table to make it quicker.
That's not a direct answer to your question, because it won't tell you real-time progress of the query, which is what you're asking for, but it does directly answer the last sentence of your question, and so it may actually be more useful to you for what you really want to know than any real-time progress report would be.

Dealing with asterisks in Sphinx results

I'm using Sphinx to search MySQL.
One of the results Sphinx returns for a search is M*A*S*H, as in the hit television show.
The problem I'm facing is that M*A*S*H is returned for nearly any query made with Sphinx. I'm guessing this is due to the asterisks. If not, then what could the problem be?
If the asterisks are causing my problem, how can I work around this to not have M*A*S*H returned for every query?
Make sure that asterisks are included in the charset_table.
charset_table = <blah blah blah>, U+002A
http://sphinxsearch.com/docs/current.html#conf-charset-table
Does this Sphinx function (EscapeString) do what you want
This problem no longer seems to exist, though I don't know why. I'm sure that something must have been amiss in my sphinx.conf. If someone else has this issue, let me know here and I'll try to update this answer accordingly.
In any case you can use the exceptions file to specify any word you may want to include in your searches. Remember to reindex whenever you change the file.
You can read the details here: http://sphinxsearch.com/docs/1.10/conf-exceptions.html

Determine if an Index has been used as a hint

In SQL Server, there is the option to use query hints.
eg
SELECT c.ContactID
FROM Person.Contact c
WITH (INDEX(AK_Contact_rowguid))
I am in the process of getting rid of unused indexes and was wondering how I could go about determining if an index was used as a query hint. Does anyone have suggestions on how I could do this?
Cheers,
Joe
You can only run profiler for client SQL or search sys.sql_modules otherwise.
To find unused indexes you'd normally use something based on dmvs. This would show you what indexes are in use and need to be kept.
That's a great question, and I don't think I can give you an easy answer. If it were me, I would script th entire database in Management Studio and do a Text search for the index name. I would also do that in all of my reports and source code, just to be sure, too.
I don't think that hints make their way to sys.dependencies for procs an functions, but even if they did, you'd have some ad-hoc SQL to potentially deal with, so that's why I'd use the text searching route.

Is it possible to apply trigger on any table in information_schema?

Is it possible to apply trigger on any table in information_schema?
It is my understanding that the tables in information_schema are really views. This is mentioned here.
According to MySQL, you can't make triggers on temp tables or views. See this page for a discussion about that.
So, I'm going to say no based on that information. I'm sure someone will correct me if I'm wrong on this.
There is a discussion similar to what you are asking here.
What are you trying to accomplish?
Someone smarter is there --
Just kidding but I've been trying to do the same thing and the only obvious answer is to add an abstraction layer, unfortunately.
Simply put, instead of just SQL("ALTER TABLE ....") you will need to call a higher level function (written by yourself) in another language, like this:
->
modifytable( $old_table_structure,$new_table_structure){
alter_table_base_table($old_table_structure,$new_table_structure);
alter_table_history_table($old_table_structure,$new_table_structure); //just guessing that's what I'm doing with it so thought it was the same for you
alter_history_triggers($old_table_structure,$new_table_structure);
}
I really wanted to do this straight in the DBMS, but it seems like information_schema wasn't meant for that.
And of course, you'll want to have all that in one transaction, to make sure it doesn't explode ;)