Search Results

Search found 9751 results on 391 pages for 'merge module'.

Page 8/391 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Node.js appears to be missing the multipart module

    - by Brenton Alker
    I am trying to parse form data, including upload files with a node.js http server. All of the tutorial type articles I have found use a require("multipart"); to include the multipart module, but when I try the same I get: Error: Cannot find module 'multipart' I also can't find it in the current api docs (though it is in the google cached version). So, has this module been removed from the standard installation or is there something else that does the job?

    Read the article

  • Incorporate Joomla module into template?

    - by thatryan
    I built a rad slider module. Then I built a template that I am going to use as a base for more projects, and I know I will use my slider module most of the time. Is there a way, other than tearing apart the modules and re-coding it all into the template, to "package" the module with a template? Like the HTML overrides do, but adding the functionality instead of overriding existing? Does this make sense? Thanks!

    Read the article

  • Bundle module with app on Google App Engine

    - by Oscar Reyes
    This may be a basic question but how can I include a module with my app. I'm very new to python and what I want to do is to include this module simplejson with my app, but after downloading it I have no idea what to do next :( This is how the module looks like after unzip it. I don't know what files to move to my app.

    Read the article

  • How to override module classes in Kohana 3?

    - by Luke
    In Kohana 3, how can I override/extend a module class? E.g. I want to add functionality to the Auth module that is specific to my application. In this case I want to extend the abstract Auth class located in the classes folder of the Auth module. What naming convention should I use for my Auth class and where in the file system do I place my class file?

    Read the article

  • Using the Module Pattern for larger projects

    - by Rob
    I'm interested in using the Module Pattern to better organize my future projects. Unfortunately, there are only a few brief tutorials and proof-of-concept examples of the Module Pattern. Using the module pattern, I would like to organize projects into this sort of structure: project.arm.object.method(); Where "project" is my global project name, "arm" is a sub-section or branch of the project, "object" is an individual object, and so on to the methods and properties. However, I'm not sure how I should be declaring and organizing multiple "arms" and "objects" under "project". var project = window.project || {}; project.arm = project.arm || {}; project.arm.object = (function() { var privateVar = "Private contents."; function privateMethod() { alert(privateVar); } return { method: privateMethod }; }()); Are there any best practices or conventions when defining a complex module structure? Should I just declare a new arm/object underneath the last?

    Read the article

  • Javascript: Using the Module Pattern for larger projects

    - by Rob
    I'm interested in using the Module Pattern to better organize my future projects. Unfortunately, there are only a few brief tutorials and proof-of-concept examples of the Module Pattern. Using the module pattern, I would like to organize projects into this sort of structure: project.arm.object.method(); Where "project" is my global project name, "arm" is a sub-section or branch of the project, "object" is an individual object, and so on to the methods and properties. However, I'm not sure how I should be declaring and organizing multiple "arms" and "objects" under "project". var project = window.project || {}; project.arm = project.arm || {}; project.arm.object = (function() { var privateVar = "Private contents."; function privateMethod() { alert(privateVar); } return { method: privateMethod }; }()); Are there any best practices or conventions when defining a complex module structure? Should I just declare a new arm/object underneath the last?

    Read the article

  • Problem with Eclipse and a Maven multi-module project

    - by earth
    I have created a Maven project with the following structure: + root-project pom.xml (pom) + sub-projectA (jar) + sub-projectB (jar) I have done the following steps: mvn archetype:create –DgroupId=my.group.id –DartifactId=root-project mvn archetype:create –DgroupId=my.group.id –DartifactId=sub-projectA mvn archetype:create –DgroupId=my.group.id –DartifactId=sub-projectB So I have, obviously, in the top-level pom.xml the following elements: <modules> <module>sub-projectA</module> <module>sub-projectB</module> </modules> The last step was: mvn eclipse:clean eclipse:eclipse Now if I import the root-project in Eclipse, it seems to look at my projects as resources and not like java projects. However if I import each of child projects sub-projectA and sub-projectB, it looks them like java projects. This is a big problem for me because I have a deeper hierarchy. Any help would be appreciated!

    Read the article

  • Managing several custom content types from one module(drupal)

    - by Andrew
    Is it possible to declare and manage several custom content types inside one module? I'm creating a site that needs four custom content types and I'd like to manage them from one module instead of creating module for every content type. After some testing, I found out that it seems impossible. Because, unless hook_form and content type share the same name of module, drupal doesn't call hook_form. Here's how I'd like to do - function mycontent_node_info(){ return array( 'mycontent1' => array( 'name' => t('....'), 'module' => 'mycontent', 'description' => t('...), 'has_title' => TRUE, 'title_label' => t('Title'), 'has_body' => TRUE, 'body_label' => t('content body'), ), 'mycontent2' => array( ....... ), 'mycontent3' => array( ...... ), 'mycontent4' => array( ...... ), ); } function mycontent1_form(&$node){ $form['control1'] = array( '#type' => 'select', '#options' => array( '0' => t('selection 1'), '1' => t('selection 2'), ), '#attributes' => array('id'=>'control1'), ); $form['control2'] = array( '#type' => 'select', '#options' => array( '0' => t('1'), '1' => t('2'), '2' => t('3'), '3' => t('4'), ), '#attributes' => array('id'=>'control2'), ); return $form; } function mycontent2_form(&$node){ .... } function mycontent3_form(&$node){ .... } function mycontent4_form(&$node){ .... } Am I doing something wrong here or is not possible and there's no alternative other than creating module for every content types. I appreciate much your help.

    Read the article

  • Load python module not from a file

    - by user575061
    Hello, I've got some python code in a library that attempts to load a simple value from a module that will exist for the applications that use this library from somemodule import simplevalue Normally, the application that uses the library will have the module file and everything works fine. However, in the unit tests for this library the module does not exist. I know that I can create a temporary file and add that file to my path at runtime, but I was curious if there is a way in python to load something in to memory that would allow the above import to work. This is more of a curiosity, saying "add the module to your test path" is not helpful :P

    Read the article

  • Merge XML files with configurable rules (context: Maven POMs, Java)

    - by Patrick Bergner
    Hi, I'm currently writing some kind of a Maven POM preprocessor that assembles a POM for a project from multiple input files (basically a template and a module specific file). The files are hierarchically ordered (template = most general, module specific = least general). The problem is now to merge these files into a single POM file. Long story short or if you're not familiar with Maven: a POM looks like this (shortened): <project> <modelVersion>4.0.0</modelVersion> <dependencies> <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-core</artifactId> </dependency> </dependencies> </project> Basically the merger shall replace all values of the more general file with the values of the more specific file (i.e. singletons, e.g. the <modelVersion> above) but there are certain elements where the merger shall add the more certain element to a parent (i.e. collections, e.g. <dependency> elements shall always be added to the <dependencies> element and no <dependency> element shall be replaced by another). A more detailed example with definition of desired output: File A: <project> <modelVersion>A</modelVersion> <dependencies> <dependency> <groupId>groupIdA</groupId> <artifactId>artifactIdA</artifactId> </dependency> </dependencies> </project> File B: <project> <modelVersion>B</modelVersion> <dependencies> <dependency> <groupId>groupIdB</groupId> <artifactId>artifactIdB</artifactId> </dependency> </dependencies> </project> Desired output: <project> <modelVersion>B</modelVersion> <dependencies> <dependency> <groupId>groupIdA</groupId> <artifactId>artifactIdA</artifactId> </dependency> <dependency> <groupId>groupIdB</groupId> <artifactId>artifactIdB</artifactId> </dependency> </dependencies> </project> The set of collection type elements are known and should be configurable (preferably via a set of XPath expressions). A Java based solution is appreciated. What looked most promising so far was the tool mentioned here but the MERGE action produces something like <dependency> <groupId>groupIdAgroupIdB</groupId> <artifactId>artifactIdAartifactIdB</artifactId> </dependency> when merging, which is not what I need. Any ideas? Thanks for your help!

    Read the article

  • Improving Partitioned Table Join Performance

    - by Paul White
    The query optimizer does not always choose an optimal strategy when joining partitioned tables. This post looks at an example, showing how a manual rewrite of the query can almost double performance, while reducing the memory grant to almost nothing. Test Data The two tables in this example use a common partitioning partition scheme. The partition function uses 41 equal-size partitions: CREATE PARTITION FUNCTION PFT (integer) AS RANGE RIGHT FOR VALUES ( 125000, 250000, 375000, 500000, 625000, 750000, 875000, 1000000, 1125000, 1250000, 1375000, 1500000, 1625000, 1750000, 1875000, 2000000, 2125000, 2250000, 2375000, 2500000, 2625000, 2750000, 2875000, 3000000, 3125000, 3250000, 3375000, 3500000, 3625000, 3750000, 3875000, 4000000, 4125000, 4250000, 4375000, 4500000, 4625000, 4750000, 4875000, 5000000 ); GO CREATE PARTITION SCHEME PST AS PARTITION PFT ALL TO ([PRIMARY]); There two tables are: CREATE TABLE dbo.T1 ( TID integer NOT NULL IDENTITY(0,1), Column1 integer NOT NULL, Padding binary(100) NOT NULL DEFAULT 0x,   CONSTRAINT PK_T1 PRIMARY KEY CLUSTERED (TID) ON PST (TID) );   CREATE TABLE dbo.T2 ( TID integer NOT NULL, Column1 integer NOT NULL, Padding binary(100) NOT NULL DEFAULT 0x,   CONSTRAINT PK_T2 PRIMARY KEY CLUSTERED (TID, Column1) ON PST (TID) ); The next script loads 5 million rows into T1 with a pseudo-random value between 1 and 5 for Column1. The table is partitioned on the IDENTITY column TID: INSERT dbo.T1 WITH (TABLOCKX) (Column1) SELECT (ABS(CHECKSUM(NEWID())) % 5) + 1 FROM dbo.Numbers AS N WHERE n BETWEEN 1 AND 5000000; In case you don’t already have an auxiliary table of numbers lying around, here’s a script to create one with 10 million rows: CREATE TABLE dbo.Numbers (n bigint PRIMARY KEY);   WITH L0 AS(SELECT 1 AS c UNION ALL SELECT 1), L1 AS(SELECT 1 AS c FROM L0 AS A CROSS JOIN L0 AS B), L2 AS(SELECT 1 AS c FROM L1 AS A CROSS JOIN L1 AS B), L3 AS(SELECT 1 AS c FROM L2 AS A CROSS JOIN L2 AS B), L4 AS(SELECT 1 AS c FROM L3 AS A CROSS JOIN L3 AS B), L5 AS(SELECT 1 AS c FROM L4 AS A CROSS JOIN L4 AS B), Nums AS(SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS n FROM L5) INSERT dbo.Numbers WITH (TABLOCKX) SELECT TOP (10000000) n FROM Nums ORDER BY n OPTION (MAXDOP 1); Table T1 contains data like this: Next we load data into table T2. The relationship between the two tables is that table 2 contains ‘n’ rows for each row in table 1, where ‘n’ is determined by the value in Column1 of table T1. There is nothing particularly special about the data or distribution, by the way. INSERT dbo.T2 WITH (TABLOCKX) (TID, Column1) SELECT T.TID, N.n FROM dbo.T1 AS T JOIN dbo.Numbers AS N ON N.n >= 1 AND N.n <= T.Column1; Table T2 ends up containing about 15 million rows: The primary key for table T2 is a combination of TID and Column1. The data is partitioned according to the value in column TID alone. Partition Distribution The following query shows the number of rows in each partition of table T1: SELECT PartitionID = CA1.P, NumRows = COUNT_BIG(*) FROM dbo.T1 AS T CROSS APPLY (VALUES ($PARTITION.PFT(TID))) AS CA1 (P) GROUP BY CA1.P ORDER BY CA1.P; There are 40 partitions containing 125,000 rows (40 * 125k = 5m rows). The rightmost partition remains empty. The next query shows the distribution for table 2: SELECT PartitionID = CA1.P, NumRows = COUNT_BIG(*) FROM dbo.T2 AS T CROSS APPLY (VALUES ($PARTITION.PFT(TID))) AS CA1 (P) GROUP BY CA1.P ORDER BY CA1.P; There are roughly 375,000 rows in each partition (the rightmost partition is also empty): Ok, that’s the test data done. Test Query and Execution Plan The task is to count the rows resulting from joining tables 1 and 2 on the TID column: SET STATISTICS IO ON; DECLARE @s datetime2 = SYSUTCDATETIME();   SELECT COUNT_BIG(*) FROM dbo.T1 AS T1 JOIN dbo.T2 AS T2 ON T2.TID = T1.TID;   SELECT DATEDIFF(Millisecond, @s, SYSUTCDATETIME()); SET STATISTICS IO OFF; The optimizer chooses a plan using parallel hash join, and partial aggregation: The Plan Explorer plan tree view shows accurate cardinality estimates and an even distribution of rows across threads (click to enlarge the image): With a warm data cache, the STATISTICS IO output shows that no physical I/O was needed, and all 41 partitions were touched: Running the query without actual execution plan or STATISTICS IO information for maximum performance, the query returns in around 2600ms. Execution Plan Analysis The first step toward improving on the execution plan produced by the query optimizer is to understand how it works, at least in outline. The two parallel Clustered Index Scans use multiple threads to read rows from tables T1 and T2. Parallel scan uses a demand-based scheme where threads are given page(s) to scan from the table as needed. This arrangement has certain important advantages, but does result in an unpredictable distribution of rows amongst threads. The point is that multiple threads cooperate to scan the whole table, but it is impossible to predict which rows end up on which threads. For correct results from the parallel hash join, the execution plan has to ensure that rows from T1 and T2 that might join are processed on the same thread. For example, if a row from T1 with join key value ‘1234’ is placed in thread 5’s hash table, the execution plan must guarantee that any rows from T2 that also have join key value ‘1234’ probe thread 5’s hash table for matches. The way this guarantee is enforced in this parallel hash join plan is by repartitioning rows to threads after each parallel scan. The two repartitioning exchanges route rows to threads using a hash function over the hash join keys. The two repartitioning exchanges use the same hash function so rows from T1 and T2 with the same join key must end up on the same hash join thread. Expensive Exchanges This business of repartitioning rows between threads can be very expensive, especially if a large number of rows is involved. The execution plan selected by the optimizer moves 5 million rows through one repartitioning exchange and around 15 million across the other. As a first step toward removing these exchanges, consider the execution plan selected by the optimizer if we join just one partition from each table, disallowing parallelism: SELECT COUNT_BIG(*) FROM dbo.T1 AS T1 JOIN dbo.T2 AS T2 ON T2.TID = T1.TID WHERE $PARTITION.PFT(T1.TID) = 1 AND $PARTITION.PFT(T2.TID) = 1 OPTION (MAXDOP 1); The optimizer has chosen a (one-to-many) merge join instead of a hash join. The single-partition query completes in around 100ms. If everything scaled linearly, we would expect that extending this strategy to all 40 populated partitions would result in an execution time around 4000ms. Using parallelism could reduce that further, perhaps to be competitive with the parallel hash join chosen by the optimizer. This raises a question. If the most efficient way to join one partition from each of the tables is to use a merge join, why does the optimizer not choose a merge join for the full query? Forcing a Merge Join Let’s force the optimizer to use a merge join on the test query using a hint: SELECT COUNT_BIG(*) FROM dbo.T1 AS T1 JOIN dbo.T2 AS T2 ON T2.TID = T1.TID OPTION (MERGE JOIN); This is the execution plan selected by the optimizer: This plan results in the same number of logical reads reported previously, but instead of 2600ms the query takes 5000ms. The natural explanation for this drop in performance is that the merge join plan is only using a single thread, whereas the parallel hash join plan could use multiple threads. Parallel Merge Join We can get a parallel merge join plan using the same query hint as before, and adding trace flag 8649: SELECT COUNT_BIG(*) FROM dbo.T1 AS T1 JOIN dbo.T2 AS T2 ON T2.TID = T1.TID OPTION (MERGE JOIN, QUERYTRACEON 8649); The execution plan is: This looks promising. It uses a similar strategy to distribute work across threads as seen for the parallel hash join. In practice though, performance is disappointing. On a typical run, the parallel merge plan runs for around 8400ms; slower than the single-threaded merge join plan (5000ms) and much worse than the 2600ms for the parallel hash join. We seem to be going backwards! The logical reads for the parallel merge are still exactly the same as before, with no physical IOs. The cardinality estimates and thread distribution are also still very good (click to enlarge): A big clue to the reason for the poor performance is shown in the wait statistics (captured by Plan Explorer Pro): CXPACKET waits require careful interpretation, and are most often benign, but in this case excessive waiting occurs at the repartitioning exchanges. Unlike the parallel hash join, the repartitioning exchanges in this plan are order-preserving ‘merging’ exchanges (because merge join requires ordered inputs): Parallelism works best when threads can just grab any available unit of work and get on with processing it. Preserving order introduces inter-thread dependencies that can easily lead to significant waits occurring. In extreme cases, these dependencies can result in an intra-query deadlock, though the details of that will have to wait for another time to explore in detail. The potential for waits and deadlocks leads the query optimizer to cost parallel merge join relatively highly, especially as the degree of parallelism (DOP) increases. This high costing resulted in the optimizer choosing a serial merge join rather than parallel in this case. The test results certainly confirm its reasoning. Collocated Joins In SQL Server 2008 and later, the optimizer has another available strategy when joining tables that share a common partition scheme. This strategy is a collocated join, also known as as a per-partition join. It can be applied in both serial and parallel execution plans, though it is limited to 2-way joins in the current optimizer. Whether the optimizer chooses a collocated join or not depends on cost estimation. The primary benefits of a collocated join are that it eliminates an exchange and requires less memory, as we will see next. Costing and Plan Selection The query optimizer did consider a collocated join for our original query, but it was rejected on cost grounds. The parallel hash join with repartitioning exchanges appeared to be a cheaper option. There is no query hint to force a collocated join, so we have to mess with the costing framework to produce one for our test query. Pretending that IOs cost 50 times more than usual is enough to convince the optimizer to use collocated join with our test query: -- Pretend IOs are 50x cost temporarily DBCC SETIOWEIGHT(50);   -- Co-located hash join SELECT COUNT_BIG(*) FROM dbo.T1 AS T1 JOIN dbo.T2 AS T2 ON T2.TID = T1.TID OPTION (RECOMPILE);   -- Reset IO costing DBCC SETIOWEIGHT(1); Collocated Join Plan The estimated execution plan for the collocated join is: The Constant Scan contains one row for each partition of the shared partitioning scheme, from 1 to 41. The hash repartitioning exchanges seen previously are replaced by a single Distribute Streams exchange using Demand partitioning. Demand partitioning means that the next partition id is given to the next parallel thread that asks for one. My test machine has eight logical processors, and all are available for SQL Server to use. As a result, there are eight threads in the single parallel branch in this plan, each processing one partition from each table at a time. Once a thread finishes processing a partition, it grabs a new partition number from the Distribute Streams exchange…and so on until all partitions have been processed. It is important to understand that the parallel scans in this plan are different from the parallel hash join plan. Although the scans have the same parallelism icon, tables T1 and T2 are not being co-operatively scanned by multiple threads in the same way. Each thread reads a single partition of T1 and performs a hash match join with the same partition from table T2. The properties of the two Clustered Index Scans show a Seek Predicate (unusual for a scan!) limiting the rows to a single partition: The crucial point is that the join between T1 and T2 is on TID, and TID is the partitioning column for both tables. A thread that processes partition ‘n’ is guaranteed to see all rows that can possibly join on TID for that partition. In addition, no other thread will see rows from that partition, so this removes the need for repartitioning exchanges. CPU and Memory Efficiency Improvements The collocated join has removed two expensive repartitioning exchanges and added a single exchange processing 41 rows (one for each partition id). Remember, the parallel hash join plan exchanges had to process 5 million and 15 million rows. The amount of processor time spent on exchanges will be much lower in the collocated join plan. In addition, the collocated join plan has a maximum of 8 threads processing single partitions at any one time. The 41 partitions will all be processed eventually, but a new partition is not started until a thread asks for it. Threads can reuse hash table memory for the new partition. The parallel hash join plan also had 8 hash tables, but with all 5,000,000 build rows loaded at the same time. The collocated plan needs memory for only 8 * 125,000 = 1,000,000 rows at any one time. Collocated Hash Join Performance The collated join plan has disappointing performance in this case. The query runs for around 25,300ms despite the same IO statistics as usual. This is much the worst result so far, so what went wrong? It turns out that cardinality estimation for the single partition scans of table T1 is slightly low. The properties of the Clustered Index Scan of T1 (graphic immediately above) show the estimation was for 121,951 rows. This is a small shortfall compared with the 125,000 rows actually encountered, but it was enough to cause the hash join to spill to physical tempdb: A level 1 spill doesn’t sound too bad, until you realize that the spill to tempdb probably occurs for each of the 41 partitions. As a side note, the cardinality estimation error is a little surprising because the system tables accurately show there are 125,000 rows in every partition of T1. Unfortunately, the optimizer uses regular column and index statistics to derive cardinality estimates here rather than system table information (e.g. sys.partitions). Collocated Merge Join We will never know how well the collocated parallel hash join plan might have worked without the cardinality estimation error (and the resulting 41 spills to tempdb) but we do know: Merge join does not require a memory grant; and Merge join was the optimizer’s preferred join option for a single partition join Putting this all together, what we would really like to see is the same collocated join strategy, but using merge join instead of hash join. Unfortunately, the current query optimizer cannot produce a collocated merge join; it only knows how to do collocated hash join. So where does this leave us? CROSS APPLY sys.partitions We can try to write our own collocated join query. We can use sys.partitions to find the partition numbers, and CROSS APPLY to get a count per partition, with a final step to sum the partial counts. The following query implements this idea: SELECT row_count = SUM(Subtotals.cnt) FROM ( -- Partition numbers SELECT p.partition_number FROM sys.partitions AS p WHERE p.[object_id] = OBJECT_ID(N'T1', N'U') AND p.index_id = 1 ) AS P CROSS APPLY ( -- Count per collocated join SELECT cnt = COUNT_BIG(*) FROM dbo.T1 AS T1 JOIN dbo.T2 AS T2 ON T2.TID = T1.TID WHERE $PARTITION.PFT(T1.TID) = p.partition_number AND $PARTITION.PFT(T2.TID) = p.partition_number ) AS SubTotals; The estimated plan is: The cardinality estimates aren’t all that good here, especially the estimate for the scan of the system table underlying the sys.partitions view. Nevertheless, the plan shape is heading toward where we would like to be. Each partition number from the system table results in a per-partition scan of T1 and T2, a one-to-many Merge Join, and a Stream Aggregate to compute the partial counts. The final Stream Aggregate just sums the partial counts. Execution time for this query is around 3,500ms, with the same IO statistics as always. This compares favourably with 5,000ms for the serial plan produced by the optimizer with the OPTION (MERGE JOIN) hint. This is another case of the sum of the parts being less than the whole – summing 41 partial counts from 41 single-partition merge joins is faster than a single merge join and count over all partitions. Even so, this single-threaded collocated merge join is not as quick as the original parallel hash join plan, which executed in 2,600ms. On the positive side, our collocated merge join uses only one logical processor and requires no memory grant. The parallel hash join plan used 16 threads and reserved 569 MB of memory:   Using a Temporary Table Our collocated merge join plan should benefit from parallelism. The reason parallelism is not being used is that the query references a system table. We can work around that by writing the partition numbers to a temporary table (or table variable): SET STATISTICS IO ON; DECLARE @s datetime2 = SYSUTCDATETIME();   CREATE TABLE #P ( partition_number integer PRIMARY KEY);   INSERT #P (partition_number) SELECT p.partition_number FROM sys.partitions AS p WHERE p.[object_id] = OBJECT_ID(N'T1', N'U') AND p.index_id = 1;   SELECT row_count = SUM(Subtotals.cnt) FROM #P AS p CROSS APPLY ( SELECT cnt = COUNT_BIG(*) FROM dbo.T1 AS T1 JOIN dbo.T2 AS T2 ON T2.TID = T1.TID WHERE $PARTITION.PFT(T1.TID) = p.partition_number AND $PARTITION.PFT(T2.TID) = p.partition_number ) AS SubTotals;   DROP TABLE #P;   SELECT DATEDIFF(Millisecond, @s, SYSUTCDATETIME()); SET STATISTICS IO OFF; Using the temporary table adds a few logical reads, but the overall execution time is still around 3500ms, indistinguishable from the same query without the temporary table. The problem is that the query optimizer still doesn’t choose a parallel plan for this query, though the removal of the system table reference means that it could if it chose to: In fact the optimizer did enter the parallel plan phase of query optimization (running search 1 for a second time): Unfortunately, the parallel plan found seemed to be more expensive than the serial plan. This is a crazy result, caused by the optimizer’s cost model not reducing operator CPU costs on the inner side of a nested loops join. Don’t get me started on that, we’ll be here all night. In this plan, everything expensive happens on the inner side of a nested loops join. Without a CPU cost reduction to compensate for the added cost of exchange operators, candidate parallel plans always look more expensive to the optimizer than the equivalent serial plan. Parallel Collocated Merge Join We can produce the desired parallel plan using trace flag 8649 again: SELECT row_count = SUM(Subtotals.cnt) FROM #P AS p CROSS APPLY ( SELECT cnt = COUNT_BIG(*) FROM dbo.T1 AS T1 JOIN dbo.T2 AS T2 ON T2.TID = T1.TID WHERE $PARTITION.PFT(T1.TID) = p.partition_number AND $PARTITION.PFT(T2.TID) = p.partition_number ) AS SubTotals OPTION (QUERYTRACEON 8649); The actual execution plan is: One difference between this plan and the collocated hash join plan is that a Repartition Streams exchange operator is used instead of Distribute Streams. The effect is similar, though not quite identical. The Repartition uses round-robin partitioning, meaning the next partition id is pushed to the next thread in sequence. The Distribute Streams exchange seen earlier used Demand partitioning, meaning the next partition id is pulled across the exchange by the next thread that is ready for more work. There are subtle performance implications for each partitioning option, but going into that would again take us too far off the main point of this post. Performance The important thing is the performance of this parallel collocated merge join – just 1350ms on a typical run. The list below shows all the alternatives from this post (all timings include creation, population, and deletion of the temporary table where appropriate) from quickest to slowest: Collocated parallel merge join: 1350ms Parallel hash join: 2600ms Collocated serial merge join: 3500ms Serial merge join: 5000ms Parallel merge join: 8400ms Collated parallel hash join: 25,300ms (hash spill per partition) The parallel collocated merge join requires no memory grant (aside from a paltry 1.2MB used for exchange buffers). This plan uses 16 threads at DOP 8; but 8 of those are (rather pointlessly) allocated to the parallel scan of the temporary table. These are minor concerns, but it turns out there is a way to address them if it bothers you. Parallel Collocated Merge Join with Demand Partitioning This final tweak replaces the temporary table with a hard-coded list of partition ids (dynamic SQL could be used to generate this query from sys.partitions): SELECT row_count = SUM(Subtotals.cnt) FROM ( VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10), (11),(12),(13),(14),(15),(16),(17),(18),(19),(20), (21),(22),(23),(24),(25),(26),(27),(28),(29),(30), (31),(32),(33),(34),(35),(36),(37),(38),(39),(40),(41) ) AS P (partition_number) CROSS APPLY ( SELECT cnt = COUNT_BIG(*) FROM dbo.T1 AS T1 JOIN dbo.T2 AS T2 ON T2.TID = T1.TID WHERE $PARTITION.PFT(T1.TID) = p.partition_number AND $PARTITION.PFT(T2.TID) = p.partition_number ) AS SubTotals OPTION (QUERYTRACEON 8649); The actual execution plan is: The parallel collocated hash join plan is reproduced below for comparison: The manual rewrite has another advantage that has not been mentioned so far: the partial counts (per partition) can be computed earlier than the partial counts (per thread) in the optimizer’s collocated join plan. The earlier aggregation is performed by the extra Stream Aggregate under the nested loops join. The performance of the parallel collocated merge join is unchanged at around 1350ms. Final Words It is a shame that the current query optimizer does not consider a collocated merge join (Connect item closed as Won’t Fix). The example used in this post showed an improvement in execution time from 2600ms to 1350ms using a modestly-sized data set and limited parallelism. In addition, the memory requirement for the query was almost completely eliminated  – down from 569MB to 1.2MB. The problem with the parallel hash join selected by the optimizer is that it attempts to process the full data set all at once (albeit using eight threads). It requires a large memory grant to hold all 5 million rows from table T1 across the eight hash tables, and does not take advantage of the divide-and-conquer opportunity offered by the common partitioning. The great thing about the collocated join strategies is that each parallel thread works on a single partition from both tables, reading rows, performing the join, and computing a per-partition subtotal, before moving on to a new partition. From a thread’s point of view… If you have trouble visualizing what is happening from just looking at the parallel collocated merge join execution plan, let’s look at it again, but from the point of view of just one thread operating between the two Parallelism (exchange) operators. Our thread picks up a single partition id from the Distribute Streams exchange, and starts a merge join using ordered rows from partition 1 of table T1 and partition 1 of table T2. By definition, this is all happening on a single thread. As rows join, they are added to a (per-partition) count in the Stream Aggregate immediately above the Merge Join. Eventually, either T1 (partition 1) or T2 (partition 1) runs out of rows and the merge join stops. The per-partition count from the aggregate passes on through the Nested Loops join to another Stream Aggregate, which is maintaining a per-thread subtotal. Our same thread now picks up a new partition id from the exchange (say it gets id 9 this time). The count in the per-partition aggregate is reset to zero, and the processing of partition 9 of both tables proceeds just as it did for partition 1, and on the same thread. Each thread picks up a single partition id and processes all the data for that partition, completely independently from other threads working on other partitions. One thread might eventually process partitions (1, 9, 17, 25, 33, 41) while another is concurrently processing partitions (2, 10, 18, 26, 34) and so on for the other six threads at DOP 8. The point is that all 8 threads can execute independently and concurrently, continuing to process new partitions until the wider job (of which the thread has no knowledge!) is done. This divide-and-conquer technique can be much more efficient than simply splitting the entire workload across eight threads all at once. Related Reading Understanding and Using Parallelism in SQL Server Parallel Execution Plans Suck © 2013 Paul White – All Rights Reserved Twitter: @SQL_Kiwi

    Read the article

  • Nullable Date column merge problem

    - by Vladimir
    I am using JPA with openjpa implementation beneath, on a Geronimo application server. I am also using MySQL database. I have a problem with updating object with nullable Date property. When I'm trying to merge entity with Date property set to null, no sql update script is generated (or when other fields are modified, sql update script is generated, but date field is ommited from it). If date field is set to some other not null value, update script is properly generated. Did anyone have problem like that?

    Read the article

  • Introspection of win32com module / pythoncom module

    - by crystal
    Hi, what is the best way to see what all functions that can be performed using pythoncom module? Specifically, i was working with the win32com module to operate upon excel files. I was not able to find introspection for it as we do for the rest of the modules. Can anyone please suggest how can i retrieve this information?

    Read the article

  • SVN Working Copy to Different Branch Merge Without Commit to Working Copy Branch

    - by Q Boiler
    If a working copy (local copy) was created from a branch, lets call it A. Coding was done in branch A, but branch A was "Closed" to commits, and branch b was opened. How do I merge my working copy changes into Branch B and commit to branch B, without commiting my changes to branch A first. Trunk - branch A. I checked out branch A and made changes. Branch A was closed to commits. New Branch created from branch A. branch A - branch B. I would like to commit my working copy changes (currently pointing at Branch A into branch B without commiting to Branch A)

    Read the article

  • Menu item for each module, with module content loading dynamically with Prism or MEF

    - by user573145
    I am developing an application currently using Prism and MEF. I would ideally like to generate a toolbar or menu with an item for each module, and when an item is clicked, only the views declared within that module load into a tab control. For example: Menu Region: ModuleA(Selected) | ModuleB Tab Region: ModuleAViewA | ModuleAViewB | ModuleAViewC Changes to Menu Region: Employees | Inventory(selected) Tab Region: Items | In Fi

    Read the article

  • Mail merge from Java

    - by Mike Q
    Hi all, Does anyone have any experience with doing mail merge from Java on a word document? I need to support both doc and docx formats. I have heard of Apache POI and docx4j. However, from reading around I'm sure how good the word support is in POI. docx4j only supports docx format as far as I can see. Can any suggest either one of the above (and correct my knowledge on support) or another appropriate library. If necessary I would be willing to use one lib for doc and another for docx. Thanks.

    Read the article

  • How to recover after a merge failure in TFS 2008?

    - by steve_d
    We recently attempted a large, "cherry picked" merge. First we did a full merge from one child development branch into the parent Main branch, then did a full merge of the Main branch into another child development branch, then we attempted to do a cherry pick merge from the second Development branch back into merge. There were many checkins, including renames and deletes; and when it wasn't working the person who was doing it did a bunch of TFPT rollbacks. What options do we have to recover here? Things like baseless, force, etc merge? Roll back to a point in time and somehow, try again?

    Read the article

  • TortoiseSvn Merge followed by Create Patch does not include new files

    - by JoelFan
    I am doing a Merge in TortoiseSvn, which modifies some files, deletes some, and adds some. Next I am doing a Create Patch to create a patch file with these changes. The problem is that the resulting patch file includes only the modifications and deletions, not the adds. I have discovered a workaround. If I revert the adds and then do an explicit Add of those files in TortoiseSVN, then do a Patch, it picks up everything, including the Adds. Is there a way to avoid this workaround?

    Read the article

  • Using Ant to merge two different properties files

    - by Justin
    I have a default properties file, and some deployment specific properties files that override certain settings from the default, based on deployment environment. I would like my Ant build script to merge the two properties files (overwriting default values with deployment specific values), and then output the resulting properties to a new file. I tried doing it like so but I was unsuccessful: <target depends="init" name="configure-target-environment"> <filterset id="application-properties-filterset"> <filtersfile file="${build.config.path}/${target.environment}/application.properties" /> </filterset> <copy todir="${web-inf.path}/conf" file="${build.config.path}/application.properties" overwrite="true" failonerror="true" > <filterset refid="application-properties-filterset" /> </copy> </target>

    Read the article

  • How can I merge the different keyboard indicators?

    - by Agmenor
    Presently I use two application indicators showing a keyboard: input methods (iBus) keyboard layout Is there a way to make them merge into one single indicator icon ? What I have in mind is the equivalent of the messaging menu (gathering all that is related to communications) or the sound menu (gathering all the controls for sound). If it is too complicated to merge the indicators, is the merge planned for an upcoming Ubuntu release? I am on Ubuntu 11.10 with Unity as my environment.

    Read the article

  • Merge a hash with the key/values of a string in ruby

    - by LazyJason
    Hi there, I'm trying to merge a hash with the key/values of string in ruby. i.e. h = {:day => 4, :month => 8, :year => 2010} s = "/my/crazy/url/:day/:month/:year" puts s.interpolate(h) All I've found is to iterate the keys and replace the values. But I'm not sure if there's a better way doing this? :) class String  def interpolate(e)    self if e.each{|k, v| self.gsub!(":#{k}", "#{v}")}  end end Thanks

    Read the article

  • Can I do a git merge entirely remotely?

    - by CaptainAwesomePants
    My team shares a "work" branch and a "stable" branch. Whenever a particular work branch is approved for further testing/release/etc, we merge it into stable. No code is ever checked directly into the stable branch. Because of this, merge conflicts simply won't happen, and it seems silly to pull down the work branch and the stable branch, merge them, and then push the changes back. Is there a git command to ask a remote git server to commit a merge of two branches that it already knows about?

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >