mysql

Is it better to create an index before filling a table with data, or after the data is in place?

I have a table of about 100M rows that I am going to copy to alter, adding an index. I'm not so concerned with the time it takes to create the new table, but will the created index be more efficient if I alter the table before inserting any data or insert the data first and then add the index? ...

a three way join mysql tables and php ?

user_table user_id | username 1 | solomon 2 | muna message table id user_id| message 1 1 | this is my first message 2 1 | this is my seocnd message 3 2 | this is muna messgae relationship table leader | follower 1 | 2 | what i want to do is a three table join...

MySQL: Limit a query to 10 rows where every index has 5 tags.

Hi, I'd like to make a query where I can retrieve an interval of 10 rows with 5 tags per each one. I have houses and tags table, I know how to do it only for simple queries with a SELECT using LIMIT but how can I do it in this case? table houses id house country 1 Grunt Mansion us 2 Hororo Suneku jp 3 Ca...

Should I add and delete index in one page?

Let's say I have players table. It consists with 3 rows(it has much more, but let's suppose it has only 3). member_id, name, exp. I use member_id row in every page so that's why I added index only to member_id. But I want to make a top players' list in one page with the highest exp. So I do something like that: $query = mysql_query("SEL...

mysql_connect() crash php-fpm on Nginx?

I have moved my web application to a new server (nginx, mysql, php) with everything the latest version. After that, I notice the application doesn't run very stable. Sometimes it is quick in response, sometimes very slow. Then I look at the 'top', 'mysql-slow-log', and error log, here what I found out: periodically, mysql-slow-log wi...

match a word from a sentence in MYSQL using regex

How can I match a word in a sentence from a column using regex? I tried: "select * from table where column regex '/\b".$text."\b/i'" but that didn't work. Thanks in advance. ...

Zend Framework slow connect to Mysql

Using Zend_Db_Profiler_Firebug and FirePHP to profile our code, all other queries after the connect is fast, but it seems to take forever for Zend Framework to establish a connection to mysql, I've googled the problem and others suggest using table metadata cache which I did, but the problem still persists. ZendDbTableAbstract::setDefau...

Table is present in SHOW TABLES; but MySQL cannot find its file...what do I do?

I am using MySQL 5.1.47 on a Mac. I have created a table named Stay in a database named LEAD. When I do a show tables command, Stay appears in the list. When I try to insert something into that table, MySQL tells me that it cannot find the 'stay' file, and gives me an errno of 2. MySQL documentation indicates that if you get an errno...

MySQL ExecuteNonQuery throws "There is already an open DataReader associated with this Command which must be closed first" Exception

Hi: I have multiple processes inserting data to the same table in my database. I am using one database connection for all the processes. When I was trying to run one of the sqlcommand, I got the above exception. I did some researching online and it seems that Mysql server only support one datareader per connection. And since each proces...

MySQL Replication: Slave cannot communicate with master (Got an error reading communication packets)

I've got 2 Ubuntu 10.04 Server virtual machines running on VirtualBox with host-only network static IP address configuration. Machine A: ubuntu-a 192.168.56.101 Machine B: ubuntu-b 192.168.56.102 Machines can ping each other via either hostnames or IP address. MySQL 5.1 installed on both systems. I want to achieve replication with ub...

PHP/Mysql: read data field value from lookup tables (split array)

I have 1 Mysql database with 2 tables: DOCUMENTS ... - staffID ..... STAFF - ID - Name The DOCUMENTS table assigns each document to a single or multiple users from the STAFF table therefore the staffID in the DOCUMENTS table consists of a comma separated array of staff ID's for example (2, 14). I managed to split the array into ...

pass array as parameter to PHP file

I am trying to create a bunch of static HTML pages from a single PHP template. I want to pass an array (a row in a MySql DB) to the .php template file, so that I can use the contents as variables and get the HTML page back. What's the best way to do this? A POST request? A function? I loop through the MySQL query results in the following...

Basic architecture guideline for web based project : cloud

We are doing small database maintenance work to earn some money. A new client asked if we can develop a shopping website to list items to sell and buy. This is to cater 300K users,(around 20K users online at same time ). Each user has custom home page, saved setting for shopping carts, items to sell, basic reports (earning etc). we...

MySQL Query to retrieve full URL slug

First question! I have a MySQL table which stores all content on the various pages of a site. Let's say there's three fields, id(int), permalink(varchar) and parent(int)(. parent is the id of it's parent page. I need a query that will build a full URL of a page, I'm guessing using CONCAT. I have it working fine for two levels, but can'...

Show Mini-Blogs From Me and Friends Only

I'm trying to make an MySQL query that will display mini-blogs from Me and My friends. Just like Twitter. Here are my tables; --members m_id INT m_user VARCHAR (rest are other member info) --shouts s_id INT s_userid INT s_content TEXT s_posted DATETIME --friends f_userid INT f_friendid INT f_status INT // 0=pending, 1=approved f_crea...

Mysql auto insert a value

Is it possible to get mysql to insert a value in a column based on whats being inserted into another column in the same table. eg: if i were to insert New York in one column, the other column could automatically be NY. Yes i'll have to store this info somewhere. But is it possible to do this? ...

MySQL performance with partition option.

Hello, I've designed mysql tables for bookings. One of them has hotels_id, rt_id, -> (room_type_id), date ..... Every rt_id has 365 rows (date). And every hotels_id has some rt_id (room types) for example 500 hotels and 8 room types per hotel -> 500 x 8 x 365 = 1.460.000 rows. I've used column index option for " hotels_id, rt_id, da...

Drupal Views Automatic Filter

I was just wondering if there was a super quick way to automatically add a filtering system into Drupal views. I.e. I just need to add in the top of my view search by name (text box) and search by category (drop down box) Or do I just manually create this form then use the filter agruments within the edit view screen? ...

Zend Framework Admin Module structure

I am creating a large web application with Zend Framework 1.10. A am new in Zend Framework(1 month experiance). Can you explain me how to create a admin module in the best way?(with own authentication). How to make this with good security? Thanks a lot. ...

PHP strtotime and MySQL UNIX_TIMESTAMP return different integer

echo strtotime('2010-09-11 12:15:01'); Returns: 1284207301 SELECT UNIX_TIMESTAMP('2010-09-11 12:15:01') Returns: 1284200101 Why the difference? ...