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. 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

  7. 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

  8. Message Board

    Date: 04/04/09 (MySQL Communtiy)    Keywords: database, web

    I want to write my own little message board.
    Post something…and allow others to respond, keeping message trees intact.

    I’ve no idea how to manage the database for something like this.
    Can anyone give me a recommendation (book or website) that might give me a clue?

    :)
    -246


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

  9. 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

  10. 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

  11. 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

  12. 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

  13. 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

  14. Converting Date in SQL Server

    Date: 10/30/09 (Asp Dot Net)    Keywords: database

    I've been looking around everywhere, but either don't know how to search for it or don't know what I'm looking at... but I'm trying to convert dates that I pull from a database from 30/10/2009 00:00:00AM or whatever it comes up as to just the date. I found a convert statement, but have no idea where to put it in my select statement (or if it goes somewhere else).

    I tried
    SELECT ID, title, caption, credit, date (CONVERT(VARCHAR(8), GETDATE(), 1) AS [MM/DD/YY]) FROM MMphotos WHERE (ID = @ID)

    and
    SELECT * FROM MMphotos WHERE (ID = @ID) CONVERT(VARCHAR(8), GETDATE(), 1) AS [MM/DD/YY]

    But neither worked... but both returned different errors. First one is saying "'date' is not a recognized built-in function name" and the second was saying "Incorrect syntax near the keyword 'CONVERT'"

    What am I mucking up?

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

  15. 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

  16. Saving Files from a Website using VB.Net

    Date: 01/28/09 (Asp Dot Net)    Keywords: html, database, web

    I have a site that we are moving from Flat HTML into a Database using in house
    written VB.Net applications. The website is roughly 10,000 pages. The volume of
    pages however is not the problem. The Page HTML content is all now held in a
    database, Now I am looping through the pages and checking each page using regular
    expressions for either a href or img src tag so I can collect the URL for all
    images and attachments. Once I have these, i pass the URL (currently) to the
    HttpWebRequest.DownloadData which makes a request to the website for the url
    provided and then the attachment is downloaded and eventually written out using
    the WriteAllBytes() function. This works for one iterration and then times out.
    What i need to know is why does it time out and is there a better method of doing
    this? the files can be rather large that are getting moved the site is about 5.7gb
    and most of this will be down to diffrent file formats.

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

  17. update form

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

    I'm trying to create an item update page for a product database, and was wondering if there's something similar to

    ConnectionString="server=...;database=...;uid=...;pwd=..."
    SelectCommand="SELECT * FROM database WHERE (ID = @ID)" >

    DefaultValue="%" />


    for updating and inserting? I use code like that for search queries, and tried changing "select" to "update" in the code to see if that might work, but no luck. I want there to be a 1st page where you select the product to be updated, then that brings you to a form that has all the product info inserted into the form (with the ID disabled), then you can edit and after submitting, it goes to the 3rd page that gives the success message and updates the table. I have the fist two pages working fine, the form populated with the right data, but after hitting submit, I don't get an error regarding the coding, but no data is updated. I tried using the datagrid method on the MSDN site, because it has worked for inserting new data, but, besides also being kinda bulky to use, it didn't work either. Any suggestions?

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

  18. 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

  19. uuugh.... database issues

    Date: 07/13/08 (Asp Dot Net)    Keywords: database, asp

    I'm trying to set up a database connection with ASP.NET in Dreamweaver MX 2004 (yeah, a little older...), and everything in the site has a check mark that needs to before you add a connection, and I add the database file, and even hit test and it registers fine. Then when I go to add a new record set, I select the database, but it says "***No table found". So apparently it's ok with the file path, it just can't read the database tables.

    I've made sure the .net framework was all good to go, and I downloaded the MDAC 2.7 files and got those all set. Is there something I'm missing? I'm trying to work with Access and asp.net because that's what a position I'm trying to move into uses, so, I don't really have other options.

    Also, I'm thinking maybe there's an issue with drivers because even when I try to hand code it with examples from http://www.w3schools.com/ASPNET/aspnet_repeater.asp, when I call it up in either IE or Firefox, it just displays the code....
    any ideas?

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

  20. [SoapDocumentMethod(OneWay = true)]

    Date: 03/17/08 (Asp Dot Net)    Keywords: database, web

    I am trying to create a "fire and forget" webservice that I can kick off from a webpage.


    This is the code I have in the webservice:

    using System;
    using System.Web;
    using System.Collections;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.Data;


    [WebService(Namespace = "http://www.tempuri.org")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]


    public class TestWebService : System.Web.Services.WebService
    {

    public TestWebService()
    {

    //Uncomment the following line if using designed components
    //InitializeComponent();
    }



    [SoapDocumentMethod(OneWay = true)]
    [WebMethod]
    public void MultipleDatabaseHits()
    {

    // ..... do a bunch of database stuff

    }


    }



    When I launch it from a page using this code, the page doesnt complete loading untill the database work is done.



    protected void Button1_Click(object sender, EventArgs e)
    {

    TestWebService mySvc = new TestWebService();
    mySvc.MultipleDatabaseHits();

    }



    What am I doing wrong ?



    I'm not using RPC for soap so I know that the [SoapDocumentMethod(OneWay = true)] command is the correct one to use. I've seen examples where [SoapDocumentMethod(OneWay = true)] came before or after [WebMethod] - I tried it in both places and it didnt make a difference.

    Source: http://aspdotnet.livejournal.com/97095.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