Search Results

Search found 22901 results on 917 pages for 'query bug'.

Page 22/917 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • Display PHP Query Array in the table

    - by Jerry
    Hi all I would like to display my Query from Mysql on the table. However, my data is like this: Array([0]=>data1, [1]=>data2, [2]=>data3,[3]=>data4,[4]=>pic1,[5]=>pic2,[6]=>pic3,[7]=>pic4); I want to display my table as |data1 | data2 |data3 |data4 |pic1 | pic2 |pic3 |pic4 I know how to display the data in the single ling like td or tr but not sure how to do tr and td on the same loop. Any helps? Thanks in advance! while($query=mysql_fetch_array($dataQuery)){ //not sure what to do here. }

    Read the article

  • Why Solr admin query page interprets UTF-8 as ISO-8859-1

    - by Scott Chu
    I deploy a war to my Tomcat 6.0.35 on Win7 64bit and when I use full-interface query page (I mean form.jsp) in Solr Admin to query 2 Chinese character (say it's C1C2) , the debug info shows: <lst name="debug"> <str name="rawquerystring">æ°è</str> <str name="querystring">æ°è</str> <str name="parsedquery">NEWSID:æ°è</str> <str name="parsedquery_toString">NEWSID:æ°è</str> ... You can see C1C2 becomes æ°è. I deploy same war file to Tomcat on Linux or on another Win7 64bit of my colleagues' computer, the encoding acts well. Does anyone know why and how can I avoid this problem? Thanks in advance!

    Read the article

  • MS SQL Query Question

    - by Lp1
    Running MS SQL 2008, and I am definitely a new SQL user. I have a table that has 4 columns: EmpNum, User, Action, Updatetime A user logs into, and out of a system, it is registered in the database. For example, if user1 logs into the system, then out 5 minutes later, a simple query (select * from update) would look like: EmpNum User Action Updatetime 1 User1 I 2010-01-01 23:00:00:000 1 User1 O 2010-01-01 23:05:00:000 I'm trying to query the Empnum, User, Action, I(in time), O(out time), and the total time. Any help or a point in the right direction, and I would be eternally grateful. :)

    Read the article

  • How to get a dynamic attribute name in cfloop over query in ColdFusion

    - by Kip
    I'm inside a cfloop over a query. I want to get an attribute, but I won't know what that attribute will be until runtime. Using #qryResult[MyAttr]# fails with the error "Complex object types cannot be converted to simple values." What is the syntax for doing this? Here is a simplified example: <cfquery datasource="TestSource" name="qryResult"> SELECT * FROM MyTable </cfquery> <cfloop query="qryResult"> <cfset MyAttr="autoid" /> <cfoutput> Test 1: #qryResult.autoid# <br/> <!--- succeeds ---> Test 2: #qryResult[MyAttr]# <br/> <!--- fails ---> </cfoutput> </cfloop>

    Read the article

  • Query to find all bars that sell three different beers at the same price

    - by Eternal Learner
    Query to find "All bars that sell three different beers at the same price?" My Tables are Sells(bar,beer,price) - bar - foreign Key.. Bars(name,addr) - name primary key. I thought of something like this but that dosent seem to work ... Select A.bar As bar , B.bar as bar From Sells AS A, Sells AS B Where A.bar = B.bar and A.beer <> B.beer Group By(A.beer) Having Count(Distinct A.beer) >= 2 Is this the correct SQL query ?

    Read the article

  • Mysql Query - Order By Not Working

    - by jwzk
    I'm running Mysql 5.0.77 and I'm pretty sure this query should work? SELECT * FROM purchases WHERE time_purchased BETWEEN '2010-04-15 00:00:00' AND '2010-04-18 23:59:59' ORDER BY time_purchased ASC, order_total DESC time_purchased is DATETIME, and an index. order_total is DECIMAL(10,2), and not an index. I want to order all purchases by the date (least to greatest), and then by the order total (greatest to least). So I would output similar to: 2010-04-15 $100 2010-04-15 $80 2010-04-15 $20 2010-04-16 $170 2010-04-16 $45 2010-04-16 $15 2010-04-17 $274 .. and so on. The output I am getting from that query has the dates in order correctly, but it doesn't appear to sort the order total column at all. Thoughts? Thanks.

    Read the article

  • Return segmented average from SQL Query?

    - by Guillaume Filion
    Hi, I measure the load on DNS servers every minute and store that into an SQL DB. I want to draw a chart of the load for the last 48 hours. That's 69120 (48*24*60) data points but my chart's only 800 pixels wide so to make things faster I would like my SQL query to return only ~800 data points. It's seems to me like a pretty standard thing to do, but I've been searching the web and in books for such a thing for a while now and the closest I was able to find was a rolling average. What I'm looking for a more of a "segmented average": divide the 69120 data points in ~800 segments, then average each segment. My SQL table is: CREATE TABLE measurements ( ip int, measurement_time int, queries int, query_time float ) My query looks like this SELECT ip, queries FROM measurements WHERE measurement_time>(time()-172800) Thanks a lot!

    Read the article

  • one query instead of four - is it possible?

    - by Syom
    i must get data from four tables. i wrote the script with four queries, but i use it in ajax, and i wan't to do it by one query. here is queries... $query1 = "SELECT `id`,`name_ar` FROM `tour_type` ORDER BY `order`"; $query2 = "SELECT `id`,`name_ar` FROM `hotel_type` ORDER BY `order`"; $query3 = "SELECT `id`,`name_ar` FROM `food_type` ORDER BY `order`"; $query4 = "SELECT `id`,`name_ar` FROM `cities` WHERE `id_parrent` = '$id_parrent' ORDER BY `name_ar`"; is it possible to write in one query? thanks

    Read the article

  • SQL Query: Using IF statement in defining new field

    - by Tofig Hasanov
    I have a table with many fields and additionally several boolean fields (ex: BField1, BField2, BField3 etc.). I need to make a Select Query, which will select all fields except for boolean ones, and a new virtual field (ex: FirstTrueBool) whose value will equal to the name of the first TRUE Boolean Field. For ex: Say I have BField1 = False, BField2 = True, BField3 = true, BField4=false, in that case SQL Query should set [FirstTrueBool] to "BField2". Is that possible? Thank you in advance. P.S. I use Microsoft Access (MDB) Database and Jet Engine.

    Read the article

  • Hibernate Query - Get latest versions by timestamp?

    - by Slim
    I have a database that is being used as a sort of version control system. That is, instead of ever updating any rows, I add a new row with the same information. Each row also contains a version column that is a date timestamp, so the only difference is the new row will have a more recent timestamp. What I'm having trouble with is writing an efficient hibernate query to return the latest version of these rows. For the sake of example, these are rows in a table called Product, the timestamped column is version. There are multiple versions of multiple products in the table. So there may be multiple versions (rows) of ProductA, multiple versions of ProductB, etc. And I would like to grab the latest version of each. Can I do this in just a single hibernate query? session.createQuery("select product from Product product where...?"); Or would this require some intermediate steps?

    Read the article

  • SQL query problem

    - by Brisonela
    Hi, I'm new to StackOverflow, and new to SQL Server, I'd like you to help me with some troublesome query. This is my database structure(It's half spanish, hope doesn't matter) Database My problem is that I don't now how to make a query that states which team is local and which is visitor(using table TMatch, knowing that the stadium belongs to only one team) This is as far as I can get Select P.NroMatch, (select * from fnTeam (P.TeamA)) as TeamA,(select * from fnTeam (P.TeamB)) as TeamB, (select * from fnEstadium (P.CodEstadium)) as Estadium, (cast(P.GolesTeamA as varchar)) + '-' + (cast(P.GolesTeamA as varchar)) as Score, P.Fecha from TMatch P Using this functions: If object_id ('fnTeam','fn')is not null drop function fnTeam go create function fnTeam(@CodTeam varchar(5)) returns table return(Select Name from TTeam where CodTeam = @CodTeam) go select * from fnTeam ('Eq001') go ----**** If object_id ('fnEstadium','fn')is not null drop function fnEstadium go create function fnEstadium(@CodEstadium varchar(5)) returns table return(Select Name from TEstadium where CodEstadium = @CodEstadium) go I hope I'd explained myself well, and I thank you help in advance

    Read the article

  • SQL Query to select upcoming events with a start and end date

    - by Chris T
    I need to display upcoming events from a database. The problem is when I use the query I'm currently using any events with a start day that has passed will show up lower on the list of upcoming events regardless of the fact that they are current My table (yaml): columns: title: type: string(255) notnull: true default: Untitled Event start_time: type: time end_time: type: time start_day: type: date notnull: true end_day: type: date description: type: string(500) default: This event has no description category_id: integer My query (doctrine): $results = Doctrine_Query::create() ->from("sfEventItem e, e.Category c") ->select("e.title, e.start_day, e.description, e.category_id, e.slug") ->addSelect("c.title, c.slug") ->orderBy("e.start_day, e.start_time, e.title") ->limit(5) ->execute(array(), Doctrine_Core::HYDRATE_ARRAY); Basically I'd like any events that is currently going on (so if today is in between start_day and end_day) to be at the top of the list. How would I go about doing this if it's even possible? Raw sql queries are good answers too because they're pretty easy to turn into DQL.

    Read the article

  • PHP mySQL query's and PHP Variables

    - by jon
    I'm trying to make an OO Login system for a project I'm working on, and am having trouble with inserting variables into the query strings. In the code below, if I replace "$TBL_NAME" with the actual table name it works. Why isn't $TBL_NAME translating to the value of $TBL_NAME? class UserDB { private $TBL_NAME = "users"; public static function CheckLogin($username, $password) { Database::Connect(); $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql="SELECT uid FROM $TBL_NAME WHERE username='$username' AND password='$password' "; $result =mysql_query($sql); $count=mysql_num_rows($result); if ($count==1) return true; else return false; } The Query is returning false.

    Read the article

  • mysql query takes 145 seconds

    - by suomee
    I have a a mysql db with myisam engine. Along with many other table I have this table "et" which has around 8137037 records. I have created indexes (individual index of column hname and pnum, it did not help much later created joint index of hname and pnum and it help execute within a second)such that queries like "select st from et where hname='name' and pnum='1' limit 1;" execute fast (with in a second) but the problem is I must execute this query "select st from et where hname='name' and pnum='1' order by id limit 1" where id is the primary key of the table and this query sometimes take 145 seconds :( how can i resolve this issue?

    Read the article

  • MySql Query to return number of photos in each album

    - by GivenPie
    MY table is set up like this, all I need to do is call a query to my Photos table. I have PhotoID as the primary key and GalleryID as the foreign key to Gallery. How can I could the number of unique PhotoID's for each multiple GalleryIDs. So to speak there are may duplicate GalleryIDs because there are many photos in a gallery. So I just need to could the number of unique PhotoIDs associated with that GalleryID. Can it be done in one query?

    Read the article

  • SQL SERVER – Introduction to PERCENT_RANK() – Analytic Functions Introduced in SQL Server 2012

    - by pinaldave
    SQL Server 2012 introduces new analytical functions PERCENT_RANK(). This function returns relative standing of a value within a query result set or partition. It will be very difficult to explain this in words so I’d like to attempt to explain its function through a brief example. Instead of creating a new table, I will be using the AdventureWorks sample database as most developers use that for experiment purposes. Now let’s have fun following query: USE AdventureWorks GO SELECT SalesOrderID, OrderQty, RANK() OVER(ORDER BY SalesOrderID) Rnk, PERCENT_RANK() OVER(ORDER BY SalesOrderID) AS PctDist FROM Sales.SalesOrderDetail WHERE SalesOrderID IN (43670, 43669, 43667, 43663) ORDER BY PctDist DESC GO The above query will give us the following result: Now let us understand the resultset. You will notice that I have also included the RANK() function along with this query. The reason to include RANK() function was as this query is infect uses RANK function and find the relative standing of the query. The formula to find PERCENT_RANK() is as following: PERCENT_RANK() = (RANK() – 1) / (Total Rows – 1) If you want to read more about this function read here. Now let us attempt the same example with PARTITION BY clause USE AdventureWorks GO SELECT SalesOrderID, OrderQty, ProductID, RANK() OVER(PARTITION BY SalesOrderID ORDER BY ProductID ) Rnk, PERCENT_RANK() OVER(PARTITION BY SalesOrderID ORDER BY ProductID ) AS PctDist FROM Sales.SalesOrderDetail s WHERE SalesOrderID IN (43670, 43669, 43667, 43663) ORDER BY PctDist DESC GO Now you will notice that the same logic is followed in follow result set. I have now quick question to you – how many of you know the logic/formula of PERCENT_RANK() before this blog post? Reference: Pinal Dave (http://blog.SQLAuthority.com) Filed under: Pinal Dave, PostADay, SQL, SQL Authority, SQL Function, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology

    Read the article

  • Fixing Chrome&rsquo;s AJAX Request Caching Bug

    - by Steve Wilkes
    I recently had to make a set of web pages restore their state when the user arrived on them after clicking the browser’s back button. The pages in question had various content loaded in response to user actions, which meant I had to manually get them back into a valid state after the page loaded. I got hold of the page’s data in a JavaScript ViewModel using a JQuery ajax call, then iterated over the properties, filling in the fields as I went. I built in the ability to describe dependencies between inputs to make sure fields were filled in in the correct order and at the correct time, and that all worked nicely. To make sure the browser didn’t cache the AJAX call results I used the JQuery’s cache: false option, and ASP.NET MVC’s OutputCache attribute for good measure. That all worked perfectly… except in Chrome. Chrome insisted on retrieving the data from its cache. cache: false adds a random query string parameter to make the browser think it’s a unique request – it made no difference. I made the AJAX call a POST – it made no difference. Eventually what I had to do was add a random token to the URL (not the query string) and use MVC routing to deliver the request to the correct action. The project had a single Controller for all AJAX requests, so this route: routes.MapRoute( name: "NonCachedAjaxActions", url: "AjaxCalls/{cacheDisablingToken}/{action}", defaults: new { controller = "AjaxCalls" }, constraints: new { cacheDisablingToken = "[0-9]+" }); …and this amendment to the ajax call: function loadPageData(url) { // Insert a timestamp before the URL's action segment: var indexOfFinalUrlSeparator = url.lastIndexOf("/"); var uniqueUrl = url.substring(0, indexOfFinalUrlSeparator) + new Date().getTime() + "/" + url.substring(indexOfFinalUrlSeparator); // Call the now-unique action URL: $.ajax(uniqueUrl, { cache: false, success: completePageDataLoad }); } …did the trick.

    Read the article

  • Running & Managing Concurrent Queries in SQL Developer

    - by thatjeffsmith
    We’ve all been there – you’ve managed to write a query that takes longer than a few seconds to execute. Tuning aside, sometimes it takes longer than you want for a query to run. So what’s a SQL Developer user to do? I say, keep going! While you’re waiting for your query to finish, there’s no reason why you can’t continue on with your work. If you need to execute something else in a worksheet, there’s no reason to launch a 2nd or 3rd copy of SQL Developer. Just open an un-shared worksheet. Now while you’ve got 1 or more queries running, you can easily get yourself into a situation where you’re not sure what’s running where. Or maybe you want to cancel a query or just check how long something’s been running. Just open the Task Progress Panel If a query or task in SQL Developer takes more than 3-5 seconds, it will appear in the Task Progress panel. You can then watch the throbbers go back and forth while you sip your coffee/soda/Red Bull. Run a query, spawn a new worksheet, run another query, watch them in the Task Progress panel. Kudos and thanks to @leight0nn for helping me get the title of this post right If you’re looking for help in managing and monitoring sessions in general, check out this post.

    Read the article

  • The long road to bug-free software

    - by Tony Davis
    The past decade has seen a burgeoning interest in functional programming languages such as Haskell or, in the Microsoft world, F#. Though still on the periphery of mainstream programming, functional programming concepts are gradually seeping into the imperative C# language (for example, Lambda expressions have their root in functional programming). One of the more interesting concepts from functional programming languages is the use of formal methods, the lofty ideal behind which is bug-free software. The idea is that we write a specification that describes exactly how our function (say) should behave. We then prove that our function conforms to it, and in doing so have proved beyond any doubt that it is free from bugs. All programmers already use one form of specification, specifically their programming language's type system. If a value has a specific type then, in a type-safe language, the compiler guarantees that value cannot be an instance of a different type. Many extensions to existing type systems, such as generics in Java and .NET, extend the range of programs that can be type-checked. Unfortunately, type systems can only prevent some bugs. To take a classic problem of retrieving an index value from an array, since the type system doesn't specify the length of the array, the compiler has no way of knowing that a request for the "value of index 4" from an array of only two elements is "unsafe". We restore safety via exception handling, but the ideal type system will prevent us from doing anything that is unsafe in the first place and this is where we start to borrow ideas from a language such as Haskell, with its concept of "dependent types". If the type of an array includes its length, we can ensure that any index accesses into the array are valid. The problem is that we now need to carry around the length of arrays and the values of indices throughout our code so that it can be type-checked. In general, writing the specification to prove a positive property, even for a problem very amenable to specification, such as a simple sorting algorithm, turns out to be very hard and the specification will be different for every program. Extend this to writing a specification for, say, Microsoft Word and we can see that the specification would end up being no simpler, and therefore no less buggy, than the implementation. Fortunately, it is easier to write a specification that proves that a program doesn't have certain, specific and undesirable properties, such as infinite loops or accesses to the wrong bit of memory. If we can write the specifications to prove that a program is immune to such problems, we could reuse them in many places. The problem is the lack of specification "provers" that can do this without a lot of manual intervention (i.e. hints from the programmer). All this might feel a very long way off, but computing power and our understanding of the theory of "provers" advances quickly, and Microsoft is doing some of it already. Via their Terminator research project they have started to prove that their device drivers will always terminate, and in so doing have suddenly eliminated a vast range of possible bugs. This is a huge step forward from saying, "we've tested it lots and it seems fine". What do you think? What might be good targets for specification and verification? SQL could be one: the cost of a bug in SQL Server is quite high given how many important systems rely on it, so there's a good incentive to eliminate bugs, even at high initial cost. [Many thanks to Mike Williamson for guidance and useful conversations during the writing of this piece] Cheers, Tony.

    Read the article

  • The long road to bug-free software

    - by Tony Davis
    The past decade has seen a burgeoning interest in functional programming languages such as Haskell or, in the Microsoft world, F#. Though still on the periphery of mainstream programming, functional programming concepts are gradually seeping into the imperative C# language (for example, Lambda expressions have their root in functional programming). One of the more interesting concepts from functional programming languages is the use of formal methods, the lofty ideal behind which is bug-free software. The idea is that we write a specification that describes exactly how our function (say) should behave. We then prove that our function conforms to it, and in doing so have proved beyond any doubt that it is free from bugs. All programmers already use one form of specification, specifically their programming language's type system. If a value has a specific type then, in a type-safe language, the compiler guarantees that value cannot be an instance of a different type. Many extensions to existing type systems, such as generics in Java and .NET, extend the range of programs that can be type-checked. Unfortunately, type systems can only prevent some bugs. To take a classic problem of retrieving an index value from an array, since the type system doesn't specify the length of the array, the compiler has no way of knowing that a request for the "value of index 4" from an array of only two elements is "unsafe". We restore safety via exception handling, but the ideal type system will prevent us from doing anything that is unsafe in the first place and this is where we start to borrow ideas from a language such as Haskell, with its concept of "dependent types". If the type of an array includes its length, we can ensure that any index accesses into the array are valid. The problem is that we now need to carry around the length of arrays and the values of indices throughout our code so that it can be type-checked. In general, writing the specification to prove a positive property, even for a problem very amenable to specification, such as a simple sorting algorithm, turns out to be very hard and the specification will be different for every program. Extend this to writing a specification for, say, Microsoft Word and we can see that the specification would end up being no simpler, and therefore no less buggy, than the implementation. Fortunately, it is easier to write a specification that proves that a program doesn't have certain, specific and undesirable properties, such as infinite loops or accesses to the wrong bit of memory. If we can write the specifications to prove that a program is immune to such problems, we could reuse them in many places. The problem is the lack of specification "provers" that can do this without a lot of manual intervention (i.e. hints from the programmer). All this might feel a very long way off, but computing power and our understanding of the theory of "provers" advances quickly, and Microsoft is doing some of it already. Via their Terminator research project they have started to prove that their device drivers will always terminate, and in so doing have suddenly eliminated a vast range of possible bugs. This is a huge step forward from saying, "we've tested it lots and it seems fine". What do you think? What might be good targets for specification and verification? SQL could be one: the cost of a bug in SQL Server is quite high given how many important systems rely on it, so there's a good incentive to eliminate bugs, even at high initial cost. [Many thanks to Mike Williamson for guidance and useful conversations during the writing of this piece] Cheers, Tony.

    Read the article

  • The Schema returned by the new query differ from the base query

    - by sochandara
    I am working on class project which required to work with Windows Application and this issue occurred to me that i don understand how to solved it can anybody help please? I want to show the NATIONALITYNAME instead of showing NATIONALITYID in the grid view SELECT COACH.COACHID, COACH.COACHFIRSTNAME, COACH.COACHLASTNAME, NATIONALITY.NATIONALITY FROM COACH INNER JOIN NATIONALITY ON COACH.NATIONALITYID = NATIONALITY.NATIONALITYID Error Message: "The Schema returned by the new query differ from the base query"![alt text][1]

    Read the article

  • the shema return by the new query differ from the base query

    - by sochandara
    I am working on class project which required to work with Windows Application and this issue occurred to me that i don understand how to solved it can anybody help please? I want to show the NATIONALITYNAME instead of showing NATIONALITYID in the grid view SELECT COACH.COACHID , COACH.COACHFIRSTNAME , COACH.COACHLASTNAME , NATIONALITY.NATIONALITY FROM COACH INNER JOIN NATIONALITY ON COACH.NATIONALITYID = NATIONALITY.NATIONALITYID Error Message: "The Schema returned by the new query differ from the base query"

    Read the article

  • SQL SERVER – Fundamentals of Columnstore Index

    - by pinaldave
    There are two kind of storage in database. Row Store and Column Store. Row store does exactly as the name suggests – stores rows of data on a page – and column store stores all the data in a column on the same page. These columns are much easier to search – instead of a query searching all the data in an entire row whether the data is relevant or not, column store queries need only to search much lesser number of the columns. This means major increases in search speed and hard drive use. Additionally, the column store indexes are heavily compressed, which translates to even greater memory and faster searches. I am sure this looks very exciting and it does not mean that you convert every single index from row store to column store index. One has to understand the proper places where to use row store or column store indexes. Let us understand in this article what is the difference in Columnstore type of index. Column store indexes are run by Microsoft’s VertiPaq technology. However, all you really need to know is that this method of storing data is columns on a single page is much faster and more efficient. Creating a column store index is very easy, and you don’t have to learn new syntax to create them. You just need to specify the keyword “COLUMNSTORE” and enter the data as you normally would. Keep in mind that once you add a column store to a table, though, you cannot delete, insert or update the data – it is READ ONLY. However, since column store will be mainly used for data warehousing, this should not be a big problem. You can always use partitioning to avoid rebuilding the index. A columnstore index stores each column in a separate set of disk pages, rather than storing multiple rows per page as data traditionally has been stored. The difference between column store and row store approaches is illustrated below: In case of the row store indexes multiple pages will contain multiple rows of the columns spanning across multiple pages. In case of column store indexes multiple pages will contain multiple single columns. This will lead only the columns needed to solve a query will be fetched from disk. Additionally there is good chance that there will be redundant data in a single column which will further help to compress the data, this will have positive effect on buffer hit rate as most of the data will be in memory and due to same it will not need to be retrieved. Let us see small example of how columnstore index improves the performance of the query on a large table. As a first step let us create databaseset which is large enough to show performance impact of columnstore index. The time taken to create sample database may vary on different computer based on the resources. USE AdventureWorks GO -- Create New Table CREATE TABLE [dbo].[MySalesOrderDetail]( [SalesOrderID] [int] NOT NULL, [SalesOrderDetailID] [int] NOT NULL, [CarrierTrackingNumber] [nvarchar](25) NULL, [OrderQty] [smallint] NOT NULL, [ProductID] [int] NOT NULL, [SpecialOfferID] [int] NOT NULL, [UnitPrice] [money] NOT NULL, [UnitPriceDiscount] [money] NOT NULL, [LineTotal] [numeric](38, 6) NOT NULL, [rowguid] [uniqueidentifier] NOT NULL, [ModifiedDate] [datetime] NOT NULL ) ON [PRIMARY] GO -- Create clustered index CREATE CLUSTERED INDEX [CL_MySalesOrderDetail] ON [dbo].[MySalesOrderDetail] ( [SalesOrderDetailID]) GO -- Create Sample Data Table -- WARNING: This Query may run upto 2-10 minutes based on your systems resources INSERT INTO [dbo].[MySalesOrderDetail] SELECT S1.* FROM Sales.SalesOrderDetail S1 GO 100 Now let us do quick performance test. I have kept STATISTICS IO ON for measuring how much IO following queries take. In my test first I will run query which will use regular index. We will note the IO usage of the query. After that we will create columnstore index and will measure the IO of the same. -- Performance Test -- Comparing Regular Index with ColumnStore Index USE AdventureWorks GO SET STATISTICS IO ON GO -- Select Table with regular Index SELECT ProductID, SUM(UnitPrice) SumUnitPrice, AVG(UnitPrice) AvgUnitPrice, SUM(OrderQty) SumOrderQty, AVG(OrderQty) AvgOrderQty FROM [dbo].[MySalesOrderDetail] GROUP BY ProductID ORDER BY ProductID GO -- Table 'MySalesOrderDetail'. Scan count 1, logical reads 342261, physical reads 0, read-ahead reads 0. -- Create ColumnStore Index CREATE NONCLUSTERED COLUMNSTORE INDEX [IX_MySalesOrderDetail_ColumnStore] ON [MySalesOrderDetail] (UnitPrice, OrderQty, ProductID) GO -- Select Table with Columnstore Index SELECT ProductID, SUM(UnitPrice) SumUnitPrice, AVG(UnitPrice) AvgUnitPrice, SUM(OrderQty) SumOrderQty, AVG(OrderQty) AvgOrderQty FROM [dbo].[MySalesOrderDetail] GROUP BY ProductID ORDER BY ProductID GO It is very clear from the results that query is performance extremely fast after creating ColumnStore Index. The amount of the pages it has to read to run query is drastically reduced as the column which are needed in the query are stored in the same page and query does not have to go through every single page to read those columns. If we enable execution plan and compare we can see that column store index performance way better than regular index in this case. Let us clean up the database. -- Cleanup DROP INDEX [IX_MySalesOrderDetail_ColumnStore] ON [dbo].[MySalesOrderDetail] GO TRUNCATE TABLE dbo.MySalesOrderDetail GO DROP TABLE dbo.MySalesOrderDetail GO In future posts we will see cases where Columnstore index is not appropriate solution as well few other tricks and tips of the columnstore index. Reference: Pinal Dave (http://blog.SQLAuthority.com) Filed under: Pinal Dave, PostADay, SQL, SQL Authority, SQL Index, SQL Optimization, SQL Performance, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >