Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Most Efficient Way To Extract Limited Data


I am currently using the following code, is it the most efficient way to extract and sort the 6 items from the database. The database currently holds over 2,500,000 rows and I want to extract the data as efficiently and quickly as possible. Code:




View Complete Forum Thread with Replies

Related Forum Messages:
Extract Data Into CSV
i have a batch file that moves my data between mysql tables. I would like also to create a csv file for that data? So if i move 5 records into a table it will also create a csv file
i would put csv code below insert statment?

INSERT INTO referral_authorization2 SELECT * FROM referral_authorization;

View Replies !
Data Extract
I have a table with the schema below and I want the output as below show also.

+-----------+----------------------+------+-----+
| Field | Type | Null | Key |
+-----------+----------------------+------+-----+
| ID | int(11) | | PRI |
| ENTRYDATE | datetime | | |
| SOURCE | varchar(13) | | |
| NWKID | smallint(2) | | |
| FLAG | tinyint(2) | | |
+-----------+----------------------+------+-----+

There are only 3 types of nwkid (1,2,3)
The output I'm looking for should look something like this
where nwkd1 is a count of nwkid = 1 and
nwkd2 is a count of nwkid = 2 and
nwkd3 is a count of nwkid = 3 and they are grouped by a date range,
between date_someday and date_someotherday

+-------+-------+-------+------------+
| nwkd1 | nwkd2 | nwkd3 | entrydate |
+-------+-------+-------+------------+
| 23 | 22 | 25 | 2007-03-27 |
| 12 | 14 | 13 | 2007-03-28 |
| 33 | 32 | 34 | 2007-03-29 |
+-------+-------+-------+------------+

How do I achieve this?

View Replies !
Extract Data
I have a database and I want to extract data from column two row two. I cannot use matching. I would like to use something like this: select col2 from mytable where row=2; but I know this does not work. I cannot use something like this: select col2 from mytable where col1 like 'such_and_such';
I just simply need to be able to select col2 row2 and extract the data. Is there a way to do this?

View Replies !
How To Extract Only The Starting Data?
I have a problem with my Mysql data. I have 2,95,67,456 lines of data which is too much and if I run this in MYSQL front-end it is telling "OUT OF MEMORY". Any way with my collegues system I have got the runned data and I have copied it to my Frontend, now it works. But my problem is if I am extracting particular data from that it is telling "ACCESS VIOLATION" so I have decided to extract only data from the first 1,00,000 lines, my question is"Is there any command in Mysql to extract data starting from 0 and ending at 1,00,000"if so can anyone tell me about that as soon as possible.

I have used SELECT ***** FROM **** WHERE **** LIKE *****(If we give this it will select the mentioned data from the whole database)

But, I want only the data from the first 1,00,000 lines

View Replies !
Extract Partial Data
On my site I display a list of 10 articles on a page. I show 10 titles plus the first 250 characters of each article. At the moment with my MySQL statement I bring all the data from the database and parse it with PHP to show the partial content text. This seems very slow to me especially if the articles are big.
If I truncate the data I bring from the database will that be a faster way to bring across the data?
What would be the best way to do this?
So far I've tried..Code:

SELECT id,title,SUBSTRING(article, 0, 250) as article,showdate from articles ORDER BY showdate DESC Limit 0,10

But that doesnt bring anything across, 'article' seems to be empty.

View Replies !
Extract Data Using Joins
I am at the point in testing where I need to create new tables to keep things 'clean.' I have a users table that has userid in it, auto incrementing as you would expect. Now I want to add another table to deal with some other things. I have seen how to extract data using joins, but now I want to know how I can relate this new table with the users one(and put the userid into the new table)

View Replies !
Extract Data From Notepad
Does anybody knows how to extract data from notepad the save it automatically to the database and automatically delete duplicate data.

for example data that must be extracted from the notepad ...

View Replies !
Most Efficient Way Of Storing Data From Multiple Accounts
As part of a system I am putting together I need to allow users to create thier own accounts on my servers. Each user can create their own account, and then have their users register for it. Each account needs it data seperate from the others, a member registered for one account should not be able to view another account and a username registered with one account should still be available to the other accounts.

The ways I have been looking at are:

1. Create a new database for every account created so that all users are kept in seperate databases.

2. Have one table for users, one for topics, one for posts etc and then associate each row within this table with the relevent account. So for example a user could register with the forum with the ID 4, so their user entry would be

Userid: 234
Username: xxxx
Password: xxxx
Forumid: 4

Then when a new member registers with any account I simply check that there is not another user with the same account ID and username. Indexes on relevent fields in this system could help speed up huge tables.

I expect to quickly have 20,000 plus accounts (and in theory it could go up to hundreds of thousands).

I guess my question is which of these methods is better from a speed point of view once we get a large number of accounts and users. Also, are there restrictions on the number of fields in a table that could cause problems?

Using MySQL by the way, on an Apache server.

View Replies !
Extract Data And Create Database:
I'm working with this webpage (PHP/MySQL solution) locally and I'd just
want to ask if there was a program that could extract all the tables and
data from this local database (fx. to an SQL string) which I then could
use to recreate the database on the server? I reckon I can't just copy
the database, or?

View Replies !
Extract Data And Create Database
I'm working with this webpage (PHP/MySQL solution) locally and I'd just
want to ask if there was a program that could extract all the tables and
data from this local database (fx. to an SQL string) which I then could
use to recreate the database on the server? I reckon I can't just copy
the database, or?

View Replies !
Extract Data According To Preset Sequence... How?
wondering whether i can make this work...

first, i will make an array like this:

Quote:

$category_id[]="10,6,9,8,3";

then i wanna extract the information( category name, category id, and sub category into array and arrange them in the preset sequence in category_id[] above.

Quote:

$query="select * from category order by $category_id[] ";
$result="mysql_query($query) or die(mysql_error());

while ($row=mysql_fetch_assoc($result))
{
echo $row['category_id'];
echo $row['category_name'];
echo $row['subcategory'];
}

the output i wish to get is like this:

Quote:

1st result:
category id: 10
category name= the name of category 10
sub category=
sub 1 category 10
sub 2 category 10
sub 3 category 10

2nd result:
category id: 6
category name= the name of category 6
sub category=
sub 1 category 6
sub 2 category 6
sub 3 category 6

3rd result:
category id: 9
category name= the name of category 9
sub category=
sub 1 category 9
sub 2 category 9
sub 3 category 9

I'm confuse in the extraction info according to the preset sequence... can anyone please share some ideas? will this idea works?

View Replies !
Most Efficient Way To Import Large Data Dump From Phpmyadmin?
I have a large data dump (export) from phpmyadmin my client just gave me - 200k - .

What's the most efficient way to import that into a new database? The new db has not defined tables since that is part of the phpmyadmin export.



View Replies !
How Do I Extract All My Text Data Input From A Php Forum?
I manage a small website using phpbb on a Solaris platform, using mysql 4.x. After being repeatedly hacked, I'd like to migrate to a less singled out forum bb, but without losing my data--most of which is in Chinese characters (so doing string searches is definitely out).

I have direct file access via ftp to the server, and i've also downloaded the corrupted files, only two of which have been modified by the hacker, namely,

phpbb_config.ISD
phpbb_forums.ISD

Unfortunately, the last previous backup the hosting company performed was some 8 months before...

View Replies !
Extract 5 Digit Column Data Into Another Column
i would like to make an update on my tables, which extract out the zip code from an address column into another new column call zipcode... coz the previous design of the table doesn't have this column.

View Replies !
Limited Permission To A Field
like making to only give permission of modification to a user but for a field in particular called POST that contains messages.

View Replies !
Limited BLOB-Size
I only can upload files to the BLOB column which are not bigger than 16 KBytes. Why. In many other mysql databases is the limit set to 3MByte.....
Can i change the max limit or is there no chance?

View Replies !
Returning Limited Sequential Rows
I have a query that returns to me all the seats that are available,
which is great but the ideal solution would be to return X number of
seats based on a seatnum (Integer).

For example, if seats 10, 11, 12 and 15-20 are available and I need 4
of them, I should get back seats 15,16,17,18.

I'm pretty sure that some sort of IF statement with a variable in the
query is the answer, but I can't seem to push through on it.

NOTE: seatnum is NOT a primary key and is not autoincrement. An
autoincrement col wouldn't work for this project as the sections, rows
and seats might get edited as things change in the hall. So I'm doing
the seat numbering myself.

If anyone could give me shove in the right direction, I'd appreciate
it. After many Google searches for "sequential" rows or records and
the like, all I get are people wanting to return record counts.

View Replies !
Limit :: Limited Number Of Records
I'm running a query to get a list of students and the class they belong to. Is there any way I can run a single query to return only 4 students from every class if there are more than 4 in some of them? The students have student ids, so I would want the first 4 student ids.

View Replies !
Selecting Limited Number Of Records
I have a table - `posts` with fields (id, author_id, title). I need to select 3 posts of each author. How can i do it?

View Replies !
Limited Configuration For Fulltext Indexes
The configuration options for the fulltext indexes are rather limited in that you can only configure the min length/stop words on the server level. Is there a technical reason why there isnt a table level or even index level configuration for this? I can't think that I am the only person who wants different fulltext index options for different databases/tables.

View Replies !
Query Limited By Contents Of An Array
I want to select all emails for volunteers that have signed up for any combination of open classes. The selected classes are contained in the array $_POST['class'].
// create a comma-delimited list of classes selected
$comma_separated_classes = implode(',', $_POST['class']);

$query2 = "SELECT email FROM volunteers WHERE class_id IN '$comma_separated_classes' ";
The WHERE . . . IN syntax isn't correct, but I can't find an example of what I need at mysql.com. What would be the correct query to select emails from all of the class_id's that are in the array?




View Replies !
Limited New User At Mysql With One Database!
example:

i have account root at linux and i want to create new user at mysql server and create database for my new user.
new user :alex
password : made
database :db_alex

TO create new user: alex
mysql> insert into user values('localhost','alex',password('made'),'Y','Y','Y','Y','Y','N','N','N','Y' ,'Y','N','Y','Y','Y');

To cresate database : db_alex
mysql>create database db_alex

Question :
what script at php and mysql to limited user : alex , to access only one database : db_alex
user alex can't access other database, except database db_alex.
user alex can't drop, modyfi and alter other database, except database db_alex.

View Replies !
Database Table Limited To 127 Rows
I created a csv file with 271 rows of information, then imported it into my database (via phpMyAdmin), only to discover that my table gets hung up on the number 127. In other words, it lists 126 rows, followed by "127" in the numerical key before it simply stops.

I deleted my primary key and refilled my table. This time, all the rows imported successfully, but the numerical key is still flawed. The numerals 1-126 display OK, after which every additional row is numbered 127.

I've had similar problems, where my table was apparently truncated because phpMyAdmin thought my table should only have X number of rows when it actually has twice that many. But I haven't figured this one out yet.

When I browse my table, I see another problem: There are columns of question marks (?) before my first table column (the numerical/primary key). Except in the first column, the question marks are occasionally replaced by the little pencil icon you click to edit a row. In other words, most rows can not be edited because they lack the pencil icon.

I normally created my tables in a spreadsheet, which I save in a csv format. But I created this csv file manually, so I wonder if that's where the problem is.

This is what row 126 in my csv file looks like:

126,"ita","<p>Italy became a nation-state (etc.)</p>
<p>A democratic republic (etc.)</p>","
",Italy<br />
Everything after
is not meant to display, and the <br /> is just a legacy of the Dreamweaver file I created this table on. I can't create this file with a spreadsheet, because the cells in my spreadsheet program only hold a limited amount of text, and some of these articles are quite long.


View Replies !
Join 2 Varchar Cols On A Limited Number Of Characters
Is is possible to join two varchar columns on a limited number of characters.

I'm comparing two address tables, and the same addresses entered could look slightly different. For example, an address could have been entered as 12345 Marina North Circle or 12345 Marina North Cir. or even 12345 Marina N Circle. A join on the first 7 characters would successfully return each of these as one related address.

View Replies !
Selecting Limited Items From A Database And Displaying On A Webpage
So I've got this PHP/MySQL program that someone wrote for me and it's working great. However, I'm trying to figure out the SQL (and subsequent PHP) to select only champion and reserve champion from the database and to display it on the page.

The achievements are all listed in the php_achieve table in my database with RelPlaceID, etc, etc. Can anyone help? Or let me know what other information I need to include for you?

Basically, I want my website to display the most recent five champion and reserve champion results (if there are five, otherwise, to list them all) for a specific horse (each horse already has an id). Help? I'm so dumb at this stuff. :-X

View Replies !
What's The Most Efficient Way?
I've done a database scheme and wonder what the most efficient way of storing certain entries would be. The site will have news, reviews and tutorials and these will be under the same categories. So I'm wondering what the best way to do design the database scheme would be.

Have one table like I've done now in the "content" table with the posibilty to differentiate the entries with the "post_type" field or have three different tables? Below is the table "content".

Field Type Null Default
post_id int(10) No
post_date datetime No 0000-00-00 00:00:00
post_text text No
post_title text No
post_cat_id int(4) No 0
post_description text No
post_name varchar(200) No
post_type int(4) No 0

View Replies !
How Efficient Is In() , And How Much Is The Most That You Should Put In An In()?
I am just wondering as to the efficiency of the in() function in MySQL.

select field1,field2,...,fieldn from table where id in(1,2,3,4,5,6, ... , n);

assuming:
id is an indexed field.
table is a VERY big table (100 000+ - 1 million+ records)

what do you think is the largest number of values you could pass to the in() function without completly flattening your server?

View Replies !
Most Efficient YES/NO...
I)
Table_A has fields Data_1, Data_2, Data_3, and Data_4; I need to determine whether value 'X' is present (at least once) in any of the Data_N fields. All I need is a YES/NO answer: YES, 'X' is present (at least once) in one of the Data_N fields of Table_A [Record number(s) not required!], or NO, 'X' is not present in any of the Data_N fields in any of the records in Table_A.

II)
Similar scenario, but this time Table_A has fields RecID, Data_1, Data_2, Data_3, and Data_4. I need to determine the RecID (none, one, or more) of every record that has value 'X' in any of the Data_N fields.

I'm looking for the query that will be fastest and most elegant to implement.

View Replies !
Quickest And Most Efficient
i run an online game. I want to give each user a ranking, based on how high thier score is.If for example, i had 20,000 players, i dont want to have to update them all one by one, it may strain the server and take a long time.
Is there another way i can assign a rank number (rank 1 has the top score and so on)

View Replies !
Efficient UPDATE
I have a table with the following structure;

CREATE TABLE my_table
(
id_1 int(11) NOT NULL ,
id_2 int(10) NOT NULL ,
stauts tinyint(1) NOT NULL DEFAULT 0 ,
PRIMARY KEY (id_1)
) Engine =InnoDB';


The table currently has arround 100,000 entries. When I try to run variations of the following statement it is taking around 4 seconds per query;

UPDATE IGNORE my_table
SET id_1 = 74240, id_2 = 5

I need it to be running a lot faster than 4 seconds per query as I need to update upwards of 100,000 records a day! My server is fairly beefy, a 3 gig dual core opeteron and is generaly running below 1.0 load.

View Replies !
Better Key, More Efficient Indexing
I have a complex query that uses UNION and I want to make this query use indexes for faster execution. Code:

View Replies !
Efficient Tables.
I am starting out on a project where I need to store GPS information. The data consists largely of a series of "Points" each consisting of a longitude,latitude and elevation.

On a typical "route" there could be hundreds of points.

My question is how can I efficiently store this information. It does not sound sensible to normalise this and add hundreds of rows to a table for each "route".

Sample data is along the lines of :

- <trkpt lat="54.016942977905273" lon="-1.4903640747070313">
<ele>82.330078125</ele>

<time>2006-09-03T07:35:41Z</time>

</trkpt>


- <trkpt lat="54.016938870772719" lon="-1.490332055836916">
<ele>0</ele>

<time>2006-09-03T07:35:42Z</time>

</trkpt>


View Replies !
EXTRACT
SELECT EXTRACT(YEAR_MONTH FROM '1999-07-02 01:02:03');

What could cause this query to return something like this:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'YEAR_MONTH FROM '1999-07-02 01:02:03' )
LIMIT 0, 30' at line 1

View Replies !
Efficient Storage Of IP Address
I am establishing a database for the purpose of logging access to my secure
webserver and am wanting to make the database as efficient as I can because
it will be doing a lot of work when the site goes live.

What is the most efficient way in a MySQL table to store remote IP
addresses? What data type should I use? Should I just go with a basic
VARCHAR(15) to allow for 4 sets of 3 digits with 3 decimal separators, or is
there a better way?

View Replies !
Efficient Placement Of Fields
is there any noticable efficiency is ordering the position of the field
types?. Like say i place the join keys in a table at the end, and varchars
and text at the top of the table does it really matter?

Also when i do a query like select * from table where id IN (1), where 1 is
usually a primary key int is that quicker than doing where id=1 or is there
no difference and is it handling the int as a string or as an int?

View Replies !
Efficient Database Structure
I have been developing a new website and i need help in deciding the best database structure for it. The site is basically a dating website with various modules like blogs, videos, comments, friends, photos etc. I have created a member table that stores all the basic profile info and created seperate tables for friends, photos, messages, blogs etc and MemberID as foreign key. Now on profile page, i want to display all info related to member like his profile info, his photos, friend list, messages etc and i have to execute 7-10 short queries on profile page for this. Also, i think Joins will not be much helpful as there is one to many relationship e.g there can be more than 1 photo for a member and i am saving each photo in a seperate record. Similar is the case for other tables?

View Replies !
Creating An Efficient Database
i'm currently writing a web based catalogue system in php using a mysql database.

the catalogue has a number of products in it from different brands.

i would like to know if it is more efficient to have each brand in a separate table then a "master" table just listing the brand name and corresponding table

or

all the products in one large table and a "master" table listing each brand in the large table. the large product table would of course have a field to state which brand the product was from.

the efficiency would be based on users being able to access the database via html browsers using php and also search the database.

View Replies !
How To Make Index Most Efficient
I have a large table (> 3,000,000 records). Each records contain a primary key like 'id' and a lots of attributes like 'age', 'department'. I want to build some indices
to accelerate my query.

I read the document which says that too many indices may slow down the INSERT and UPDATE operations. So is there any rule on how to set indices in such table? If I create an index for every field, would that be a very bad idea? If I create an index on each of two fields but not on their combination, will the indices contribute to queries on the combination?

View Replies !
Efficient Way To Count Rows
I'm trying to get the number of rows in a table with a very large number of records in it (~9 million). When I run a select count(*) for some criteria (where name='something', etc) it takes around 6-8 secs for the query to return the value. I tried by using SQL_CALC_FOUND_ROWS with a very small LIMIT but then the query was taking even longer.

I'm using InnoDB, with query caching enabled. I could look at the information_schema and get the approximate row count but whenever I use a where clause it'll be way off mark.

View Replies !
Efficient Way Of Mass Indexing?
I have been working on a program that will populate and index a database. The populating doesn't take too long, but the indexing does. My question is: Is there a better approach to indexing this table than the one I'm using right now?

I'm doing this through QtSql. headers is a QString array of 48 column names I want to index.

for (int i = 0; i < headers.size(); ++i) {
q.exec("ALTER TABLE mysqltable ADD INDEX(" + headers[i] + ");");
}

example run for 20000 rows:
viper,david $ time ./main -r 20000
Database Connection Established
0.520u 0.060s 0:21.27 2.7% 0+0k 0+0io 0pf+0w

View Replies !
Is This INSERT With SELECT As Efficient As Possible?
I'm writing a pretty complex web app and will be repeating many times over a query very similar to below and need to know if there is a more efficient way to do it. If anyone has input, I'd be happy to hear:

INSERT INTO table (somecolumn) VALUES ((SELECT id FROM other_table WHERE foo = 'bar'))

View Replies !
Is Between Date More Efficient For Query?
PHP

//grab rows from yesterday
WHERE (month(articles.date) = month(now()) AND
dayofmonth(articles.date) = (dayofmonth(now())-1) AND
year(articles.date)=year(now()))




View Replies !
Is This An Efficient MySQL Setup?
I would like to offload the MySQL server from my dedicated box in order to speed up page loads.

I don't have an additional dedicated server so my only option is to get a VPS.
But is offloading the MySQL server to a VPS, albeit a modest one, even worthwhile?

I understand this is a very broad question because I am not providing any details but that being the case I am expecting a broad answer

View Replies !
Efficient Way To Left Join?
What is the most efficient way to do a table join, but even if there is no matching foreign key, still return the table on the left.

SELECT col, col2, COUNT(col3)
FROM tbl1 t1
LEFT JOIN tbl2 t2
ON t1.id = t2.id
GROUP BY t1.id

But this only works if there is a matching foreign key on t2, I would like all t1 rows to return regardless of whether they exist on t2 or not.

View Replies !
Extract, Transform
We have an old legacy database at my company called CIMPRO, running on
a SCO UNIX box. We're trying to find a way to connect to the CIMPRO
database, grab the data, and send it to a Mysql database.
I've been able to successfully connect to the database using PHP and
ODBC to view the data in the tables.
i'd like to find a way to run a Linux tool or script to connect to the
database, do an initial copy of the table structure from the legacy
database to Mysql (on the linux box) and then copy selected data.
If that is doable I'd also like to be able to refresh the table data
periodically (e.g., cron job) either by deleting and reimporting or by
checking to see what has changed.

View Replies !
Extract And Compare
I was requested to do a report which consists in:
Report total sales (for example) in month: XX
Now, The user has 2 options:
- Actual month (default)
- A month choosen from (month name? or month number?)
I'd like you to help me in these 2 steps...
1. How to get records which were "saved" in actual month ?
2. How to compare and make queries if user selects month name or month number ?

View Replies !
Extract Specified Part
In one of my table, I have a date type field in format 0000-00-00, in my php syntax, how can I extract the year part only? i.e. only 2005 from 2005-07-08. I searched the help from mysql reference, but too tired for me now

View Replies !
Extract First Sentence
I have a field called "body" which contains a whole bunch of text (complete sentences). I would write a query to pull this part of the DB but I ONLY want to show the first sentence! How can I do so?

View Replies !
Extract Function
Is there any way to adapt the EXTRACT function to work on multiples of minutes, hours etc.
In the example below I would like to count the distinct opid's in an hour for a 2 min or a 5 min interval.
I do not want to use a while loop to make multiple queries.
Code:
SELECT EXTRACT(minute FROM arrived) AS themin, count(DISTINCT(opid)) AS op_count
FROM `chatEntries`
WHERE `arrived` >= '2008-04-01 00:00:00' AND arrived <= '2008-04-01 23:59:59'
GROUP BY themin

View Replies !
Extract By Date
I'm trying to make my script show Live Dates that haven't happened yet from my DB.
But the syntax is wrong: DATE_FORMAT(date,'%a, %b %D, %Y') AS date WHERE date >= CURDATE()
How should this be done? Code:

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved