1. Efficient full-text searchs on large sets of data

    Date: 10/15/10 (MySQL Communtiy)    Keywords: mysql, database, sql

    A database application I've written uses a table with around 600,000 rows. Each row has a text field 500-5000 characters long. I periodically need to find all the rows containing a particular phone number, name, or address, ie.'123-4567', 'john smith', '1950 Main St N'

    I'm doing this using
    SELECT * FROM `tb_archive` WHERE `text` LIKE '%john smith%' ORDER BY `date` DESC

    The problem is that it is too slow. Most searches take 30-60 seconds. If multiple searches are done the server response begins to slow to a crawl for other users.

    I've looked at mysql built in full-text indexing - but I'm not sure if it can work since I only need exact matches, don't care about relavence, and often search for numbers and short words.

    Any suggestions as to how I can do this more efficiently?

    Source: http://mysql.livejournal.com/138390.html

  2. Database in SVN

    Date: 10/09/09 (MySQL Communtiy)    Keywords: mysql, database, sql

    Anyone know how to store a MySQL database schema (and maybe data from some tables hopefully based on table structure) into SVN?

    Source: http://mysql.livejournal.com/137943.html

  3. Effective coding

    Date: 09/22/09 (MySQL Communtiy)    Keywords: mysql, database, sql

    I found an instruction set that said to list the first, and last name of all employees that had neither 'SON' nor 'DAUGHTER' listed in their dependency files. I came up with a query that gave me the results I wanted by assuming the database only takes SPOUSE, SON, and DAUGHTER, but assuming has always caused me trouble, so I would like to know: Is there any better way I could have gone about approaching this so it's not going by a general assumption of dep_relation = 1, and so forth?



    
    mysql> SELECT * FROM dependent;
    +-------------+------------+------------+-------------------+------------------+
    | dep_emp_ssn | dep_name   | dep_gender | dep_date_of_birth | dep_relationship |
    +-------------+------------+------------+-------------------+------------------+
    | 999444444   | Jo Ellen   | F          | 1996-04-05        | DAUGHTER         | 
    | 999444444   | Andrew     | M          | 1998-10-25        | SON              | 
    | 999444444   | Susan      | F          | 1975-05-03        | SPOUSE           | 
    | 999555555   | Allen      | M          | 1968-02-29        | SPOUSE           | 
    | 999111111   | Jeffery    | M          | 1978-01-01        | SON              | 
    | 999111111   | Deanna     | F          | 1978-12-31        | DAUGHTER         | 
    | 999111111   | Mary Ellen | F          | 1957-05-05        | SPOUSE           | 
    +-------------+------------+------------+-------------------+------------------+
    
    
    mysql> SELECT * FROM employee;
    +-----------+---------------+----------------+
    | emp_ssn   | emp_last_name | emp_first_name |
    +-----------+---------------+----------------+
    | 999666666 | Bordoloi      | Bijoy          | 
    | 999555555 | Joyner        | Suzanne        | 
    | 999444444 | Zhu           | Waiman         | 
    | 999887777 | Markis        | Marcia         | 
    | 999222222 | Amin          | Hyder          | 
    | 999111111 | Bock          | Douglas        | 
    | 999333333 | Joshi         | Dinesh         | 
    | 999888888 | Prescott      | Sherri         | 
    +-----------+---------------+----------------+
    
    
    
    What I generated was:
    
    SELECT emp_first_name, emp_last_name 
    FROM 
    	(
    	SELECT emp_first_name, emp_last_name,
    	dep_relationship, COUNT(dep_relationship) AS count 
    	FROM dependent 
    	JOIN employee ON dep_emp_ssn = emp_ssn 
    	GROUP BY emp_ssn
    	) tempTable 
    WHERE tempTable.count = 1 
    AND tempTable.dep_relationship != 'SON' 
    AND tempTable.dep_relationship != 'DAUGHTER';
    
    To get:
    
    +----------------+---------------+
    | emp_first_name | emp_last_name |
    +----------------+---------------+
    | Suzanne        | Joyner        | 
    +----------------+---------------+
    



    So really, I covered the "Son nor Daughter" case, but it's the count = 1 that I feel could be "bettered" so to speak.


    I appreciate the feedback. ;]

    Source: http://mysql.livejournal.com/137636.html

  4. MySQL

    Date: 08/07/09 (MySQL Communtiy)    Keywords: mysql, database, sql

    I am not entirely sure if this is the right place to ask but I thought to give it a shot anyway.
    I want to create a new MySQL Database so I downloaded MySQL 4.1.22 for Windows and installed it. After installing it I have the program MySQL Command Line Client and MySQL Server Instance Config Wizard. For both of them I need a root user name and a root password but how do I know those, where can I find them?
    i hope you can help me.

    Source: http://mysql.livejournal.com/137190.html

  5. oracle blob to mysql blob *update*

    Date: 07/20/09 (MySQL Communtiy)    Keywords: php, mysql, xml, database, sql

    hey again
    i'm trying to convert an oracle db to mysql. so far everything is going ok except for the files in the db. the old admin was storing jpg, pdf, doc, xml files and whatever else you can think of into a blob field in the table on oracle.

    is this the best way to do things? i mean sure all you need to do is back up the database and presto you have all the files. but i'm having a hell of a time getting a backup. 440 entries in the table comes up to a 180 megabyte text file. phpmyadmin won't process the file because it times out, sqlyog and navicat are having trouble with the file size saying they're running out of memory.


    the closest i've come to completing this transfer is using toad for oracle and outputting the table to an mdb file. then in navicat i use the wizard and import the mdb, it sees the fields of the table perfectly, but the blobs come out having 0k. aside from that small issue i keep getting error 2006 when importing. and lose between 3 and 219 entries depending on the time i'm importing.

    so, at a loss, am i doing things right? is it possible to convert oracle blobs to mysql blobs? personally if i had written the original site i would just save a link to the actual file in the db and not store the actual file in the db. does that make sense?


    *UPDATE*
    so i tried using the migration tool, no luck. i'm missing libraries and my tech guy wasn't here yesterday. the site for the oracle libraries didn't want to work either.
    so this is what i ended up doing:
    in toad i saved a csv/txt file of the table without the blobs in the csv. cut the size down to 88k.
    i uploaded that via sqlyog into the db. no problems.
    then in toad i saved the blobs themselves as individual .dat files. so at least i have the files this way.
    the db actually has the filename in it, so it was just a simple extracting the filename, copying the .dat files from one folder to another on the server with a simple php script and changing the names to reflect their actual names. all the files can be opened no problem once the name have been changed.

    now i just need to link to said files from db to directory on the server.

    thanks again for the input :)

    Source: http://mysql.livejournal.com/136836.html

  6. Searching and counting

    Date: 07/14/09 (MySQL Communtiy)    Keywords: mysql, sql

    I have some difficulties in building a right query for a situation. A MySQL Table 'patients' looks like this

    Name Doctor Date
    -------------------------------
    John Deere Dr.Watson 2009-02-11
    Bill Fairy Dr.Dylan 2009-03-03
    John Deere Dr.Dylan 2009-05-19

    I'm trying to count records with same Name field AND all other fields in reply must contain appropriate field in LAST record (based in Date field). I'm doing following query:

    SELECT *, COUNT(*) AS num FROM patients GROUP BY name, HAVING COUNT(*)>1 ORDER BY date DESC;

    I think that ORDER BY DESC helps me to get in reply fields of last record. But in reply I always receive data contained in my oldest record :( I stumbled :) Anyone can help?

    Thanks in advance.

    Source: http://mysql.livejournal.com/136661.html

  7. Is ref: NULL bad?

    Date: 06/23/09 (MySQL Communtiy)    Keywords: mysql, sql

    In the EXPLAIN below, is ref: NULL a bad thing?

    mysql> explain SELECT * FROM mytable WHERE item_id='09N1320347' AND value_id IN (2,3,4,5,6,7,8,9);
    +----+-------------+------------------------+-------+---------------+-------+---------+------+------+-------------+
    | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
    +----+-------------+------------------------+-------+---------------+-------+---------+------+------+-------------+
    | 1 | SIMPLE | mytable | range | PRIMARY,item_id | item_id | 18 | NULL | 6 | Using where |
    +----+-------------+------------------------+-------+---------------+-------+---------+------+------+-------------+
    1 row in set (0.00 sec)

    Indexes:
    Keyname Type Cardinality Action Field
    PRIMARY PRIMARY 2240917 item_id, color_id
    item_id INDEX 93371 item_id, value_id

    Source: http://mysql.livejournal.com/135843.html

  8. Best schema for these requirements?

    Date: 06/19/09 (MySQL Communtiy)    Keywords: mysql, database, sql

    I've been handed a legacy app with a mysql database to extend/upgrade. The system is a mess. Lab tests are stored in a single table, with over 200 columns containing marker values. The labtest table includes the DateTestCollected. A separate table holds patient demographics, including DateOfBirth and Sex.

    In the past, we scanned lab results and identified possible abnormalities based on one or more markers. The same cutoff values were used regardless of age or sex. So -- SELECT COUNT(*) FROM labtest WHERE marker_1>$m_1_cutoff_high OR marker_1<$m_1_cutoff_low; Even with the less than ideal schema, indexes on the marker columns made this kind of query work relatively well.

    New algorithms are being put into place. Instead of just looking at one or two markers, we now must look at the age & sex to determine which cutoff values to use, then apply our algorithm. I now have 12 possible variations of the same algorithm.

    (ie:

    WHERE
    date_of_test>'2008-01-01' AND
    date_of_test<'2008-04-01' AND
    (

    ( age_rage='0-9' AND sex='m' AND ( marker_1 < 876 AND marker_1 > 345) ) OR
    ( age_rage='10-19' AND sex='m' AND ( marker_1 < 824 AND marker_1 > 312) ) OR
    ( age_rage='20-29' AND sex='m' AND ( marker_1 < 798 AND marker_1 > 311) )

    ) OR (

    ( age_rage='0-9' AND sex='f' AND ( marker_1 < 987 AND marker_1 > 465) ) OR
    ( age_rage='10-19' AND sex='f' AND ( marker_1 < 813 AND marker_1 > 404) ) OR
    ( age_rage='20-29' AND sex='f' AND ( marker_1 < 701 AND marker_1 > 209) )

    ) OR (
    /* ect */
    )

    There are actually 12 variations to check against. This query is very slow, especially when iterating through 200+ markers (200 x 12 variations). EXPLAIN showed that MySQL is scanning all rows (50,000) - as soon as I applied a multi-column index (date_of_test, marker_1) MySQL stopped scanning the entire table.

    Under the current schema, each marker, age, sex, and date_of_test column is indexed separately (no multi-column indexes). There are limits to the number of indexes per table.

    So that's where I am. I have a legacy system in need of work, but I'm not sure of the best, most efficient way of approaching the problem.

    I thought of converting the labtest table to something like (labtest_id, marker_id, marker_value), but that alone doesn't solve the issue of having to find the age & sex of each patient to determine the correct marker cutoff value.

    What would be the least painful way of working through this?

    Source: http://mysql.livejournal.com/135617.html

  9. Pivs Not Showing Up?

    Date: 06/05/09 (MySQL Communtiy)    Keywords: mysql, database, sql

    Hi Folks. I'm hoping this is a simple question, but its baffling me.

    I have a mySQL 5.0.27 DB. I am trying to give people "show view" and "create view" privs for a specific database. When I execute the commands to do this, they seem to be accepted with no problem - no syntax error, no warning. However when I then do a show grants on the person the "view privs" do not show up, and they confirm that they do not have those privs.

    I have flushed privileges as well, which was my first thought, but that is not the case.

    I do seem to be able to grant or revoke other privs.

    Views are new to us, but they were included in 5.0.1 so I should have them.

    Anyone have any thoughts?

    Source: http://mysql.livejournal.com/135180.html

  10. Indexes and DB Writes...

    Date: 03/30/09 (MySQL Communtiy)    Keywords: mysql, database, sql

    We are all familiar with how valuable indexes are to mySQL (and in general) database reads. However - and specifically with respect to mySQL - what effect to indexes have to database writes?

    A colleague of mine, as we are changing our DB indexing structure, has argued that indexes harm database writes since the data must be written to the database and to the index. This is a compelling argument. However, in my last job in working with Sybase SQL databases we had instances where indexes would greatly increase write efficiency apparently. I had specific experience that this was the case, but no one was able to explain to me how that was the case given what I could see where the data would have to be written in two separate places.

    So, how do indexes effect the efficiency of database writes in mySQL?

    Source: http://mysql.livejournal.com/133925.html

  11. Selective Replication in mySQL 5.X

    Date: 02/03/09 (MySQL Communtiy)    Keywords: mysql, database, sql

    Folks may remember last week when I was asking questions about mysqldumps. I was doing that in order to get a DB backup for a specific database we wanted to replicate on another server, and I've been working on that.

    After some hit and miss I think I nearly got it working, at least to a point where the replication started between the Master and the slave. It seemed to work for a few seconds, then bombed when the slave tried to execute a statement that was for a DB that it didn't have in it.

    The point is that of all the several databases on the Master machine, at this point we only want to replicate one on the slave machine. I thought I had had that set up in the slave's my.cnf with the line

    replicate-do-db - aid #aid is the database we want to replicate

    however High Performance MySQL says that this is not the way to do this since filtering will be done on the current default database. "This is not usually what you want." :-)

    The book does indicate that "On the slave, the relicate_* options filter events as the slave SQL thread reads them from the relay log." This make sense to me, and at this point it also makes sense that the log coming from the master has every statement coming into the DB. It goes on to say that "You can replicate or ignore one or more databases (emphasis mine)...based on LIKE pattern matching syntax." There is where I lose it. I understand how to use the LIKE syntax in mySQL statements, but not in this environment.

    Is it possible to set up a small battery of statements in the slave my.cnf along the lines of:

    replicate_ignore_table = .%

    Would that do it?

    Is anyone basically doing replication in a simple Master-Slave relationship where you are only replicating one DB? If so, how are you doing it?

    THANKS, folks!

    Source: http://mysql.livejournal.com/133717.html

  12. Restoring from a mySQLDump...

    Date: 01/28/09 (MySQL Communtiy)    Keywords: mysql, database, sql

    Folks, I'm having what I think is a weird problem restoring a DB from a mysqldump. What I'm trying to do is basically copy a DB from one mysql database server to another.

    The mysqldump command I used originally was:

    mysqldump --quick --add-locks --extended-insert -u root -p dbname > dbname.sql

    When this didn't work upon restoration I also tried:

    mysqldump --opt -u root -p dbname > dbname.sql

    Both these commands created the dbname.sql file with no problems or complaints.

    I copied the SQL file over to the target computer. I went into mySQL as root and did:

    create database dbname;
    use dbname;
    source dbname.sql;

    The import would start, but it wouldn't get very far. In the end, after not many seconds it would just...stop. Here is an example:


    Query OK, 8708 rows affected (0.11 sec)
    Records: 8708 Duplicates: 0 Warnings: 0

    Query OK, 8750 rows affected (0.12 sec)
    Records: 8750 Duplicates: 0 Warnings: 0

    Query OK, 8740 rows affected (0.11 sec)
    Records: 8740 Duplicates: 0 Warnings: 0

    Query OK, 8758 rows affected (0.11 sec)
    Records: 8758 Duplicates: 0 Warnings: 0

    Query OK, 8745 rows affected (0.12 sec)
    Records: 8745 Duplicates: 0 Warnings: 0


    And it would just stop here. I waited several minutes, and the load average of the machine went down to normal levels. The mySQLd stopped showing up on top.

    I'd then CNTRL-C the process and get:


    ^CQuery aborted by Ctrl+C
    ^CAborted
    mysql: 0 files and 1 streams is left open

    $


    I've done this a few times and the results have been consistent(ly bad). As I mentioned I also did two separate mysqldumps and both files failed to import the same way.

    While the import was happening I watched "top." There didn't seem to be a memory issue since the mysqld never used more than 0.3% of the memory, although it did use 96% of the CPU (which was fine).

    The mysqlds are running on the same operating system - Fedora 10 x_64. The only difference between them is the dump was done on mysql 5.0.27, and I am trying to source to a mysqld v5.0.67.

    Any thoughts?

    Source: http://mysql.livejournal.com/133572.html

  13. calling remote stored procedure

    Date: 12/17/08 (MySQL Communtiy)    Keywords: mysql, database, sql

    I need to "synchronize" the output of a stored procedure in one database (I don't have access to any tables there, just stored procedures) and a table in another database. So I need to call a remote stored procedure once in a while and populate a local table with its output. For the remote database, I know hostname, port, username, password and db name.

    Is this possible in mysql? Any help would be appreciated

    Source: http://mysql.livejournal.com/133145.html

  14. MySQL IDE options

    Date: 12/11/08 (MySQL Communtiy)    Keywords: mysql, database, sql

    I'm starting a new consulting gig that requires me to work on a MySQL database. Typically, I use Rapid SQL as my IDE, but I have been informed that it doesn't support 5.x. What IDEs out there support MySQL 5?

    Source: http://mysql.livejournal.com/132964.html

  15. Entity Synonym Names

    Date: 12/07/08 (MySQL Communtiy)    Keywords: html, sql, google

    Heyo. I'm putting together a user search function and I would like to include a Facebook-style name recognition system that understands name synonyms. A search for Will would also return Bill and William, for example. To some extent I could see a Soundex search kinda accomplishing this, but I'm wondering if anyone has any really good ideas as to how to implement this. At the moment I'm trying to find a sql dump of name synonyms which I would use for cross-references.

    Anyone done this before and have some words of wisdom?

    *update*

    I've found this: http://answers.google.com/answers/threadview/id/778986.html

    ... which is definitely helpful.

    I created a SQL file and posted about it here: http://danconnor.com/wordpress/?p=138

    I'm still open to suggestions though!

    Source: http://mysql.livejournal.com/132846.html

  16. ... 42nd

    Date: 01/30/17 (HTML Help)    Keywords: mysql, sql

    Things have been progressing recently. Been able to push my spirit to move forward and troubleshoot some errors involving form input of data to mysqli and now it's a bit progressing. I'm really looking forward to finish my project. Hopefully next month i would be able to finish it all and maybe publish it for beta. I think I need a definite "MUSTS" lists of task so i would know and scratch it off if it's done and do what needs to be done next. Will do that later, I think.
    Meanwhile, I also saw a posts of for rent in quezon city area.. One I would describe is if I am going to base the photo, the place is cool to hangout with, and not just an ordinary place to stay or rent to. There's a patio, a hangout area and I think it would give you a HOME type of vibes or vibration-..ish?..... There's a street, as it says, or foodtrip street area nearby- 'the strEAT' why not name it like that? lol  and nearby University of the Philippines Diliman.

    Source: http://htmlhelp.livejournal.com/2507088.html

  17. Using DataRelation in DataSet

    Date: 05/28/10 (Asp Dot Net)    Keywords: sql

    Hi everybody!
    This is the question about how to use DataRelation object.
    Let's say I have 2 tables:
    SELECT customerId, customerName FROM customers
    and
    SELECT orderId, customerId, orderName FROM orders
    which are related by customerId.

    Assume I have method

    getDataSet(sqlTextArray)

    which returns me the DataSet based on array of queries sqlTextArray

    So, then I can write:

    String q1 = 
       "SELECT c.customerName, r.orderId, r.orderName "+
       "FROM customers AS c, orders as r "+
       "WHERE (c.ustomerId = r.customerId) ";
    String[] q = new String[] { q1 };
    
    DataSet d = getDataSet(q);
    DataTable t = d.Tables[0];
    for (int i=0; i < t.Rows.Count; i++) {
       String s = t.Rows[i]["customerName"] + ", " + 
          t.Rows[i]["orderId"] + ", " + t.Rows[i]["orderName"] + ".";
       Console.WriteLine(s);
    }
    

    This part is clear for me. Then, I want to achieve the same result by using
    DataRelation. In this case I should write something like this:
    String[] q = new String[] { 
       "SELECT customerId, customerName FROM customers", 
       "SELECT orderId, customerId, orderName FROM orders" 
    };
    DataSet d = getDataSet(q);
    d.Relations.Add(new DataRelation("customer2order",
       d.Tables[0].Columns["customerId"],
       d.Tables[1].Columns["customerId"]));
    

    How to print out the combined data as I did that in first example?

    Source: http://aspdotnet.livejournal.com/104432.html

  18. Drag and Drop Listbox

    Date: 02/17/09 (Asp Dot Net)    Keywords: database, asp, sql, web

    Hi,
    What I am trying to do this time is create an asp.net listbox from
    an SQL Server 2005 result set (done) which then users can sort the
    records to form the running order within the same Listbox and then
    submit all the records including the new running order back into
    the database. Each record has already been automatically assigned
    a running order number based on their position in the old website.

    I am looking for suggestions on the quickest and *easist* way to do
    this, examples would be much appreciated. My web application is asp.net
    written in C#.

    Any help is appreciated.

    Source: http://aspdotnet.livejournal.com/103147.html

  19. Access the XSD file, Computer says no!

    Date: 11/28/08 (Asp Dot Net)    Keywords: database, sql

    I keep getting an error the error 1) in my code, I am using a xsd file to call stored procedure and
    access the database. This worked fine under Windows 2000 using visual basic express 2005. I am now
    on a XP Machine using VS 2005 and i can get it to work. The error occurs at this point 2) and the
    code that defines that dataaccess is listed as 3). So what am i doing wrong then all suggestion
    accepted.

    1) Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

    2) content_page = dataaccess.GetContentPages()

    3)

    Dim content_page As Object
    Dim page As Object
    Dim page_number As Integer
    Dim page_content As String

    ' call out the pages from the database
    Dim dataaccess As DataSet1TableAdapters.pagesTableAdapter = New DataSet1TableAdapters.pagesTableAdapter
    content_page = dataaccess.GetContentPages()

    ' Loop through the record set
    For Each page In content_page
    ' assigned the page and content values to variables
    page_number = page
    page_content = page

    Source: http://aspdotnet.livejournal.com/101914.html

  20. .net Class based on SQL Query

    Date: 09/11/08 (Asp Dot Net)    Keywords: php, sql

    I have wrote small script to create container-class based on SQL query (or CSV list of vars)

    http://akb.awardspace.com/build_class_based_on_sql.php

    Wrote primarily for myself, but everybody is welcome to use it.

    Source: http://aspdotnet.livejournal.com/100912.html

Previous page  ||  Next page


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home