1
vote
1answer
16 views

Optimizing indexes

I just began optimizing my schemas with indexes (pretty late I guess). I never dealt with huge dataset but I'll be soon coping with about 1 to 5 millions rows. Here is the schema I'm using right now ...
0
votes
1answer
15 views

Can I estimate the row count of a large mysql table using the disk space?

Sysadmin here (not a developer by trade), so go easy please ;) I have a mysql table, on a linux server that uses innodb_file_per_table. When I try to do select count(foo) from table; It doesn't ...
4
votes
1answer
51 views

sql indexing and performance

I am using mysql5.1, i have table which has about 15 lakh (1.5 million) records.This table has records for different entities i.e child records for all master entities. There are 8 columns in this ...
1
vote
0answers
32 views

Any idea why this seemingly-simple query is really slow?

Here's the query SELECT count(*) FROM registration r LEFT JOIN registration r2 ON r.baggage_group_id = r2.baggage_group_id AND r2.team_id IS NULL WHERE r.event_id = "102577"; It seems pretty ...
0
votes
0answers
23 views

MySQL Query for combobox

I have two tables in my database.namely books and bookidofid. where bookidofid from books table is referenced to bookidofid from bookidofid table Table books ...
0
votes
1answer
24 views

How can I rewrite the following removing the date_format function?

I have a table with a column when that is of type datetime. I am doing the following filter which can not use and index: AND DATE_FORMAT(t1.when, '%Y-%m-%d') <= LAST_DAY(now() - interval 1 month ) ...
0
votes
0answers
24 views

How to use Select query just right after Insert on master in a query.?

I have a question on mysql replication. As usual, I deployed my db structure like the Update on master db, the select on slave. My questions. If I use SELECT query just right after INSERT in a query, ...
0
votes
1answer
32 views

Optimize this query: SQL

I have this query in MySQL: SELECT p.idSentence, p.idPath, p.token, p.posTag, p.ner, p.isTV, r.relationType, t.tag FROM path p LEFT OUTER JOIN relation ...
-1
votes
2answers
54 views

When do I need transactions /locks?

I know that transactions are meant to group several operations as one. But if for example in the same table one transaction does DELETE FROM table where state = 'done' and another does either SELECT ...
0
votes
0answers
29 views

Why does the delete/update block each other in this case?

The following drives me crazy. I have: session1>begin; session2>begin; session2>update dummy set salary=1000 where id=11; session1>delete from dummy where id=1; id is the PK ...
0
votes
1answer
43 views

limiting rows in joins

So I have this problem with one of my queries. The query is meant to get data from table patients and join the table patient_nurse, then table nurses to it. The patients table is as follows id | ...
2
votes
2answers
71 views

Problem translating MySQL to PostgreSQL

We're using Trac for issue tracking. I migrated it from MySQL to PostgreSQL, but some of the ticket queries no longer work. In the below, all I did this far is replace IFNULL() with COALESCE() and ...
0
votes
3answers
34 views

How to create an Access query to find # symbol into a field?

It seems easy but I'm missing something. I have a MySQL database that is connected from access through ODBC connector. I'm looking for the fields where there are # symbol but I'm getting zero ...
0
votes
1answer
51 views

Why is this query slow, it seems simple

I have a very typical table of user information for my application, with an average set of columns (ints, varchars, etc). In this table are two varchar(100) fields: emailAddress and emailAddress2. ...
0
votes
1answer
31 views

Restore InnoDB from .frm files

My database crashed and my PC and I now only have the .frm and .ibd files left. Is there any way to restore my database?
0
votes
1answer
23 views

How to overwrite csv file of MySQL result set?

My SQL query is given below, select company.Company_name as COMPANY_NAME, IFNULL(followup.contact_date, ' ') AS FOLLOW_UP_DATE, IFNULL((select Full_name from user where user_id = followup.user_id), ...
0
votes
3answers
50 views

Get only future records

I have the following query: SELECT master.master_id, master.showname, MIN(CONCAT(shows.show_date, ' ', shows.show_time)) AS first_show_date, MAX(CONCAT(shows.show_date, ' ', shows.show_time)) AS ...
1
vote
1answer
24 views

merge rows based on column

I have attendance_log table : +----------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | ...
0
votes
1answer
17 views

mysql - Waiting for table level lock on a table

I have a problem with my website.. The last few days, at random times the website has become very slow. I started to investigate the best I could. I saw that the MySQL process was using 85 - 95% of ...
0
votes
1answer
66 views

Delete Query takes a long time

I have a innodb table that counts circa 1 billion entries. I started a delete operation (with a small where condition on an indexed column) that should delete a lot entries, leaving circa 100 million. ...
0
votes
0answers
27 views

MySQL import gets slower and slower until it virtually grinds to a halt, what can I do to maintain constant speeds?

I'm importing a large set of sql data into a MySQL (MariaDB 5.5) database, the files are from 200mb to 3g. I'm importing it one after the other, and it starts importing at speeds around 1MiB/s to ...
1
vote
2answers
48 views

How to Log All mysql queries into log file?

I am using Mysql 5.6.12 under Wamp server environment. Now I want to log All queries into ".log" file, the queries which are running by PHP or from PHPMyAdmin, I want to log them...
0
votes
1answer
59 views

UPDATE CONCAT without duplicates

I would like to concatenate multiple values ​​and remove duplicates (case-insensitive) in the same field with SQL only. Without using a unique key or stored procedure. Ex. ...
0
votes
1answer
38 views

Is there any way to get the estimate cost of executing a query in MySQL?

In PostgreSQL, EXPLAIN or EXPLAIN ANALYZE will show the estimate cost of executing a query. But EXPLAIN in MySQL doesn't provide this information. How can I get the estimate cost without installation ...
0
votes
2answers
34 views

MySQL query optimization for legacy application

I'm working with a legacy application that started out with little data years ago (developed by a third party custom for this client), and now we're seeing MySQL load skyrocket on this query alone. ...
0
votes
0answers
28 views

Alphanumeric field in MySQL

I need to create a character field with some rules, they are, Field name: contract_number. Rules: Contract Number Contract number must be alphanumeric. Contract number must be unique. Contract ...
0
votes
0answers
13 views

How to Replicate data from read only sql database to Active one

We are applying logs in every 30 min to one SQL db which has to be in Restoration Mode/Read only mode as we are applying logs continuously. Now we have to Set up Replicaion of this Read only Db to ...
-3
votes
0answers
37 views

How to update top 10 rows in all Departments

i Have A 109 of Industry's and Date Wise JobPosts in job_post Table like Table: Job_post Field1: jobpost_id Field2: jobpost_date Field3: jobpost_Industry *How i Update Every Industry's top ...
1
vote
1answer
18 views

Make MySQL dump from parts of each table

I need to export some data from different tables. I tried this query select * into outfile 'C:\Users\\User\\Desktop\\ololo.sql' from db.users where id % 2 = 1; After this query, the SQL file was ...
0
votes
1answer
40 views

Is not in (a,b,c) faster than where != a, b, c

When writing a query which is faster? SELECT * FROM table where column not in (a,b,c); or: SELECT * FROM table where column != a AND column != b AND column != c ;
0
votes
0answers
12 views

Analyze a Database to Find Failed Foreign Key Constraints

I aggressively deleted a ton of data after using this query: SET FOREIGN_KEY_CHECKS = 0; Is there any easy way I can analyze the entire database to check to see if I have any hanging records that ...
0
votes
1answer
33 views

How to query-and-increase a value (counter) in a thread-safe way? (avoid race conditions)

In a table where each row has a counter (just an integer value), I need to get the current value and increase it at the same time. Effectively, I want to do this: SELECT counter FROM table WHERE ...
0
votes
0answers
16 views

using another table column as array

SET @qdate := '2014-02-17'; SELECT com.trading_code, com.business_segment_id, dmkt.close_price, dmkt.cdate, dmkt.turnover, dmkt.volume, sh.total_no_share, ...
0
votes
2answers
65 views

How to drop table with all reference to this table

I want to drop a table, and this table has be many table's foreign key. So I want to drop all those reference (just refernece, not other table) within the drop table process. Is there any simple ...
0
votes
0answers
24 views

Writing a Query to enter and update multiple data in a table [closed]

I am new to mysql and trying my best to learn. I was able to develop a solution for my needs but it is taking hours to update the records. till now only 10000 records are updated in past 3 days and ...
0
votes
0answers
37 views

Conceptual data model for a billing system

I am working on existing MySQL database, my task is to create a new data model for a billing system on that existing application, I have created a conceptual data model, as given below, My ...
0
votes
3answers
79 views

Database update query for split and sum in another field using mysql

I have one table test ID text sum ----------------------- 1 1_2_3 0 2 2_3_4_5 0 i want to update this table as ID text sum ...
2
votes
2answers
46 views

How to merge column in mysql depending on match

I have one table which looks like this in mysql column1 column2 name column3 data 1 1 foo 1 1.5 1 1 foo 2 2.5 1 1 foo 3 ...
1
vote
0answers
48 views

Tagged questions

I have similar to StackExchange network that utilises tagged questions. In my web application Users also can find questions by tags. The query below returns a set of tagged questions: SELECT ...
1
vote
2answers
57 views

Storing a Shipping Address Best Practice

I'm building a checkout system which needs to store the customer's shipping address in the database and am unsure the best way to go about it. Currently I have an addresses table which stores each ...
1
vote
1answer
23 views

creating table result in errno 150

I'm trying to create the following schema, but I'm getting errors when I'm trying to create project and staffphone tables. Not sure what is it complaining about. mysql> CREATE TABLE staff( ...
1
vote
1answer
48 views

Generate INSERT statement from SELECT query

I have two databases, in first database I have a table called zoom_city and in the second database I have a table called courrier_city. The SQL for each is below: CREATE TABLE IF NOT EXISTS ...
1
vote
0answers
28 views

Script to query MongoDB with PHP [closed]

With Code Igniter and MySQL I do: $this->database->query('select * from table'); But I don't know how to use MongoDB. Can I still use this the same way to query MongoDB? ...
0
votes
2answers
24 views

Return row in given date

I have a MySQL table named tasks that contains four columns: id (Integer) name (Varchar) task_start (DateTime) task_finish (DateTime) How can I write an SQL statement that returns tasks that are ...
0
votes
2answers
65 views

Want to show last month highest scorer details grouped by week

I have a table of data: id | name | userid | score | date | -------------------------------------------------------- 1 | john | 4 | 233 | 2014-02-02 2 | ...
1
vote
2answers
34 views

SQL Booleans vs ManyToMany

As I understand it, one way to 'abstract' a parent/child relationship in SQL would be to have a table set up with a joining foreign key table. Ie in this case, the swimsets are children of different ...
1
vote
1answer
50 views

How does the transactions interact if you set a different isolation level per connection?

I read that I can have different isolation levels per connection and in the server. The default isolation level is REPEATABLE-READ. So if I have a transaction that issues a SERIALIZED to the client ...
1
vote
2answers
53 views

Transaction basics. What is the result of 2 transactions running concurrently?

I have a rather basic question on transactions. Assume a table Account with a column amount. Now we have the following code: BEGIN $amount = SELECT amount FROM ACCOUNT WHERE id = 123; $amount = ...
0
votes
1answer
43 views

MySQL DB structure with Main category and several nested sub categories

I am looking to create a set of fields on my webpage identical to what eBay uses on their category selection page when you are selling something. For my purposes I am doing motorcycles, power sports, ...
2
votes
1answer
129 views

What is the difference between MySQL and PostgreSQL in terms of writing SQL queries? [closed]

Other than performance and security is there really any difference between MySQL and Postgres like SQL queries, built-in functions, procedures and so on? I'm asking this because I'm familiar with PHP ...