26

Re: Business of the logician in

HBM>> horizontal scaling is always cheaper than the vertical. G> in practice vertical is cheaper. G> and even banal calculations show it. We assume that the iron price grows linearly capacities. G> to scale the server horizontally to you it is necessary it . That is to buy the same disk set, the same processor, the same mother, as much storages. That is to incur double expenses. G> that it is not necessary to scale vertically all to buy in the double size because the system rests against something one. For example a disk or the processor, occasionally in storage. Therefore vertical scaling manages more cheaply. Here we rest or against restrictions on gland, or in  which cannot simply load all piece of iron and will continue to brake G> Besides at horizontal scaling costs on start of a system software grow. OS always eats a part of resources and the more at you computers, the eats OS more. Axis it is possible always , and she will eat almost insignificant part of resources. I generally would not take it into account. G> in practice the price for iron grows more slowly, than linearly. 16  cost cheaper, than 2 on 8, the disk on  costs more cheaply two on 500 . The processor in 2 times is not twice more expensive than the slow faster. G> it is finite such dependence it is saved not always if we take scales of Google or  there vertical  or it is physically impossible or costs strongly more than the horizontal. But it is Google and , such scales in life very few people can see. And vertical scaling is more favourable to normal applications. We here not consider a specific example, and we dream, so to say G> Esteem about stackoverflow, at their loadings they are scaled vertically in the core. SO in difference from others simply try to squeeze out of iron as much as possible. It abruptly. But nevertheless their architecture initially  on horizontal scaling.

27

Re: Business of the logician in

Hello, Gattaka, you wrote: HBM>> who hinders to pull out only that data which needs and be not to dragged the superfluous? G>  hinders. At me, we admit  the table on essence, and from this essence it is necessary for steam of columns for the report.  all essence pulls out and further you will work with that field that is necessary for you. What at you for ORM?

28

Re: Business of the logician in

Hello, gandjustas, you wrote: G> Typical application is CRUD. In simple application CRUD it is 100 % of all operation with basis, in difficult - not less than 60 % on my counts. Even CRUD for ORM not such simple business, for example in the same NHibernte thus it is necessary to open its transactions mandatory. Otherwise leak , it in that case does not release them. G> high-efficiency data reading is under construction on a simple principle - as much as possible exact predicate (without everyones t is done. Field = @p or @p is null) for sampling and a minimum projection. G> it means that will be necessary for you or 100500 procedures for data reading, or to glue a line in SQL. G> anybody is natural in senses so does not do and uses requests of a general view, with nonoptimal projections and predicates, receiving high-speed performance certainly is worse than that could be. G> as to change of the data, a pattern too not in favor of procedures. In case of change \adding \removal of single line no difference with requests from application is present. G> But if it is necessary to add \update \remove at once some lines ORM simply form  and send on the server, and it is necessary for procedure the data  in any xml\json or on  in tabular parameter. Then  parameter in procedure and only after that to fulfill operations. Naturally approach with procedures also is certainly nonoptimal. Wait a moment. Most the common example at me in basis lies 10  records in a label, I need to find in this heap  to my criterion to increase a field by two and to interpose records in two other labels. The decision with stored procedure obviously. The decision with ORM - it is necessary to pull out the data from a DB,  them in effect, to make business the logic and went again to basis on an insertion. Here at the expense of such transfusions ORM also loses, and it is strong. But business of the logician not in  and it is beautiful"G> the SQL text which more laconic and it is better read has no relation to high performance. Well it was the second argument: 1. Productivity, 2.  and expressiveness. All the same SQL very powerful he allows you to request that is necessary for you, instead of as  the data.

29

Re: Business of the logician in

Hello, Sinix, you wrote: S> Here /  / project requirements / the DBMS in  depends on language. S> if language is not able in linq,  (to substitute a jamb to taste), the project allows to waste time on attending of scripts at each refactoring, and the DBMS optimizer chokes on the elementary requests (we will not speak who, but  in this sense still anything), yes - presence / absence ORM smaller of problems. If you at an initial stage approached competently to a system design structure of labels - rarely changes. If it is frequent, something not that in conservatory... That the optimizer did not choke use a SQL Server at it very good optimizer, I speak on a private experience. Here these children confirm: https://www.youtube.com/watch?v=AW87RzZJ0Z0 G>> And as a whole from  much more problems, than advantage. S> well a pancake. ORM not in itself works, it should be used in a stack. I.e. Plus local transactions, plus change tracking plus serialization of changes on a network, + handling in one transaction of the data which are declared in different assembly (i.e. the general  as that, is not present) + clever  + automigration / autodevelopment both  and . Change tracking - angrily. You should trace changes, instead of be fastened on specific ORM. S> It as paper drawings vs designing in digit - the main scoring turns out, when all line-up, up to instrumental control is used. "Uncle Vasja with  digit otherwise turns out does not understand - a sediment your digit". Anything similar! It is faster as the prof. a photocamera against a soap tray. The soap tray allows you not  about an exposure, iso, diaphragms. But now you too can do photos directly as the photographer. Similarly with ORM what for to read about SQL and databases if it is possible to work with normal and customary classes, itself somehow  and it will be fulfilled. Here only in practice of it does not happen also extreme there are DBMS in this history.

30

Re: Business of the logician in

Hello, IT, you wrote: IT> That at you for ORM? Well I know about yours ... At me NHibernate and Entity Framework was. But the idea is vicious.

31

Re: Business of the logician in

Hello, gandjustas, you wrote: HBM>>>> to optimize sql it is necessary when there are problems with performance. 90 % of operations of application it  CRUD, and with it any ORM perfectly consult. G>>> nonsense. It is necessary to write the optimum code at once. Premature pessimization leads to projects, which and for half a year not . HBM>> premature optimization not smaller harm. The code should be normal, but there is no sense to pursue for +1 % of performance. G> it is incorrect. G> when Dijkstra wrote about premature optimization it meant small khaki at level of separate commands of the processor which give an insignificant gain of high-speed performance, but considerably worsen readership. G> partially same concerns a choice , it is better than type at first  the linear search, than to catch bugs in binary search with interpolation. G> But when we speak about high-level optimization - at level of data structures, component interactions, databases, it is necessary to optimize from the very beginning, differently then the correction price grows exponentially. G> optimization SQL concerns just such type of optimization. <... An implementation example through an ass ...> G> there is a situation of nonoptimal structure of a DB then it is necessary not to rewrite simply requests is even worse, but also given to pour and God forbid application works for the customer. That you describe that not absolutely truly. From this that I saw, an example of premature optimization at high level normally such:  something large. And in the course of excavation of potential problems bottle necks are visible some. Which will be the main thing depends on behavior of users, and nobody knows it (here so processes in the company are constructed business that anybody precisely does not know as will use a feature/component/product, and even as use current features. I.e. normal assumptions it is impossible to make.). Here there is "architect" and produces: "the loading Model will be here such <the description of imaginations>". Therefore we all architecture, grind towards the speed on such model. And under these imaginations there are no facts, so it seemed to easier person. In a case if he does not guess, such "" system to alter under other model of loading much more difficult than neutral. And accordingly the normal decision, in a situation when we do not know will be exact that a neck, to make neutral model and the nobility as we will trace necks that will do  during this moment as we will change system behavior when any combination from them works... Besides angrily preliminary optimization should not justify the decision through an ass. If at once it is visible that the decision does not hold rated loading - in its fire chamber.

32

Re: Business of the logician in

Hello, Gattaka, you wrote: IT>> That at you for ORM? G> Well I know about yours ... At me NHibernate and Entity Framework was. But idea . You selected two worst representatives heavy ORM and do outputs about idea. The first, by the way, for a long time already become rotten . The second imbibed in itself(himself) all worst ideas of the first.

33

Re: Business of the logician in

Hello, Gattaka, you wrote: G> If you at an initial stage approached competently to a system design structure of labels - rarely changes. If it is frequent, something not that in conservatory... That the optimizer did not choke use a SQL Server at it very good optimizer, I speak on a private experience. Here these children confirm: https://www.youtube.com/watch?v=AW87RzZJ0Z0 And here it is a classical error of the programmer, it is necessary to disaccustom to which all analysts first of all (from them and had heard plenty). Aka "I here one" or "works on small - will work and on big". Well here imagine the average sizes biz-department under any erp: The command from 10 persons (actually developers - half, from them with experience - the person three at the best), number of entities in data model -  from one and a half thousand (it is a little more), the command should finish a product under new clients and under legislation changes (next  a minimum few times in a quarter), instead of to spend time on "corrected - all broke". Here on such  all  type "can be made all manually", "scripts are easy for supporting" or "all is possible  in advance" the maximum disappears in a week. G> that the optimizer did not choke use a SQL Server at it very good optimizer, I speak on a private experience. About,  spread  aka "free sql express it is enough" / "all clients are ready to buy adult MS SQL".  is not present, at least support postgre is necessary. And there, alas, fear and a pain, and with all stack, from administrative tools and to jambs in the provider ADO.Net. However, normal orm here rescues, yes. G> Change tracking - angrily. You should trace changes, instead of be fastened on specific ORM. . When the typical business scenario -  in 40 sheets A4 and in it only the biz-logician, without implementation details, last that you wants to do - to inflate the code in n time only to trace all corrections manually. I remind, the code should be still written so that was corrected  after the next adjustment  together with the customer. I.e. the it will be closer to the initial text - the better. If that, the error price ", the line was lost" at the best - a free fix (consider, heated up native office  on 5 mythical ) in the worst - loss of clients (about delights of operation with civil services  we will not be). G> it is similar with ORM what for to read about SQL and databases you it is exact with ORM worked?  any, . The person incapable independently to reproduce/diagnose/repair a problem, lives in developers not for long. And knowledge SQL / ability to dig in the existing code here - the most basic skills.

34

Re: Business of the logician in

Hello, Gattaka, you wrote: G> Even CRUD for ORM not such simple business, for example in the same NHibernte thus it is necessary to open its transactions mandatory. Otherwise leak , it in that case does not release them. It is such joke? CRUD performed by linq2db G> Wait a moment. Most the common example at me in basis lies 10  records in a label, I need to find in this heap  to my criterion to increase a field by two and to interpose records in two other labels. The decision with stored procedure obviously. The decision with ORM - it is necessary to pull out the data from a DB,  them in effect, to make business the logic and went again to basis on an insertion. Here at the expense of such transfusions ORM also loses, and it is strong. But business of the logician not in  and "beautifully" Same linq2db supports not only DML, but also DDL, and it, for example, operation with temporary tables that in turn means that on LINQ it is possible to write the code which  the floor of basis and thus does not lift on the client of any record.

35

Re: Business of the logician in

Hello, Sinix, you wrote: S> When the typical business scenario -  in 40 sheets A4 and in it only the biz-logician, without implementation details, last that you wants to do - to inflate the code in n time only to trace all corrections manually. I remind, the code should be still written so that was corrected  after the next adjustment  together with the customer. I.e. the it will be closer to the initial text - the better. S> if that, the error price ", the line was lost" at the best - a free fix (consider, heated up native office  on 5 mythical ) in the worst - loss of clients (about delights of operation with civil services  we will not be). And on the client these changes as are traced? I about INotifyPropertyChanged well there  everyone, illumination red  fields?

36

Re: Business of the logician in

Hello, Gattaka, you wrote: whether G> So badly to implement business the logic in high-efficiency stored procedures? I had to support once such project. I will not remember that for all my career other project which would be so difficult for supporting came across to me. Subjective, certainly. But I was not lonely in such estimations of that project. The main complexity of support of that project was in stored procedures, business was aggravated with that procedures were written by the professional SQL-developer, and it was supported then C# full-stack by developers to whom was uneasy to read multipart cross-DB requests with heap JOIN', CROSS-APPLY, MERGE and other delights.

37

Re: Business of the logician in

Hello, HeBpuMHeCkaTuHa, you wrote: HBM>>> horizontal scaling is always cheaper than the vertical. G>> in practice vertical is cheaper. G>> and even banal calculations show it. We assume that the iron price grows linearly capacities. G>> to scale the server horizontally to you it is necessary it . That is to buy the same disk set, the same processor, the same mother, as much storages. That is to incur double expenses. G>> that it is not necessary to scale vertically all to buy in the double size because the system rests against something one. For example a disk or the processor, occasionally in storage. Therefore vertical scaling manages more cheaply. HBM> here we rest or against restrictions on gland, or in  which cannot simply load all piece of iron and will continue to brake If we rest what to increase resources of one server it is impossible or too expensive then and it is possible to consider horizontal scaling. Not earlier. If we rest against a software it is necessary to alter a software or to take another. G>> besides at horizontal scaling costs on start of a system software grow. OS always eats a part of resources and the more at you computers, the eats OS more. HBM> an axis it is possible always , and she will eat almost insignificant part of resources. I generally would not take it into account. Business not only in an axis. Any copy of application has the fixed overhead charge. G>> in practice the price for iron grows more slowly, than linearly. 16  cost cheaper, than 2 on 8, the disk on  costs more cheaply two on 500 . The processor in 2 times is not twice more expensive than the slow faster. G>> it is finite such dependence it is saved not always if we take scales of Google or  there vertical  or it is physically impossible or costs strongly more than the horizontal. But it is Google and , such scales in life very few people can see. And vertical scaling is more favourable to normal applications. HBM> we here not consider a specific example, and we dream, so to say It is necessary not to dream, and to consider. G>> esteem about stackoverflow, at their loadings they are scaled vertically in the core. HBM> SO in difference from others simply try to squeeze out of iron as much as possible. It abruptly. HBM> but nevertheless their architecture initially  on horizontal scaling. Forgive, in what place? They initially made ASP.NET the web application with basis on a SQL Server. The first is obviously scaled horizontally, the second obviously is not present. All web applications have the Same architecture hardly less, than.

38

Re: Business of the logician in

Hello, Gattaka, you wrote: G> Hello, gandjustas, you wrote: G>> Typical application is CRUD. In simple application CRUD it is 100 % of all operation with basis, in difficult - not less than 60 % on my counts. G> even CRUD for ORM not such simple business, for example in the same NHibernte thus it is necessary to open its transactions mandatory. Otherwise leak , it in that case does not release them.  NHibernate, take EF or linq2db, there there are no such problems. G> wait a moment. Most the common example at me in basis lies 10  records in a label, I need to find in this heap  to my criterion to increase a field by two and to interpose records in two other labels. The decision with stored procedure obviously. It is the real scenario? You can describe it in terms of the user? Or you imagined and consider, what for the sake of the such there is all crud in  to do? In a reality you will have a scenario such: 1) the Choice of lines by criterion and display to the screen 2) the Call of this business logic of the lines specified by the user. Here the logic in application on two orders fulfills is better. G> the decision with ORM - it is necessary to pull out the data from a DB,  them in effect, to make business the logic and went again to basis on an insertion. Here at the expense of such transfusions ORM also loses, and it is strong. But business of the logician not in  and it is beautiful"Only in life the similar scenario meets in OLAP-systems where generally there is no"application". G>> the SQL text which more laconic also is better read has no relation to high performance. G> well it there was a second argument: 1. Productivity, 2.  and expressiveness. All the same SQL very powerful he allows you to request that is necessary for you, instead of as  the data. , write the request satisfying following conditions: 1) If the user the administrator it to show all records 2) If the user not the administrator - to show it records where the user = the author - or the author of record is included into group of friends of the current user - and records should not be hidden 3) Records have to be filtered on a category which the user (id selected categories - a query parameter, can be empty) Thus request should be as much as possible laconic and fast.

39

Re: Business of the logician in

Hello, Gattaka, you wrote: G> And on the client these changes as are traced? I about INotifyPropertyChanged well there  everyone, illumination red  fields? Well it works for the code of the healthy person from a box. At us it is for this purpose used  a stack, and it already existed by the time of when I came to a command. A problem that traditional  is not so especially actual because of a mode on a web / rest api. And I very much and very much doubt that something similar quits in , target audience a zero.

40

Re: Business of the logician in

Hello, gandjustas, you wrote: G> Vykini NHibernate, take EF or linq2db, there there are no such problems. You will be , but we threw out before EF. There was a painful passage on NH... At EF too a heap of lacks, for example it is not allowed to receive to you pure domain objects. That is in classes of domain entities at you  links to types from EF, and it is not correct. I, for example, should use freely domain essence on the client without dragging there ORM... And requests at EF it is simple  some, NH in this plan it is better, though too . G>> Wait a moment. Most the common example at me in basis lies 10  records in a label, I need to find in this heap  to my criterion to increase a field by two and to interpose records in two other labels. The decision with stored procedure obviously. G> it is the real scenario? You can describe it in terms of the user? G> or you imagined and consider, what for the sake of the such there is all crud in  to do? Do not trust. , here to you real business the scenario. There is a computer network in which there are network points and users. They have communications among themselves, it is we all we store in basis and we give the chance through our application . Tables User (Id, Name, Property), Network_Node (Id, Name, Property), User_User (User1Id, User2Id), Network_Node (Node1Id, Node2Id), UserOnNode (NodeId, UserId) In our basis of 70000 nodes on one user on a node (for simplicity). Users are connected all to all. For some (approximately half) nodes sign Prorepry has been put down - now it is necessary to add for such nodes on which there are  the bound users. Especially count the size of table User_User, it is pleasant moment G>>> the SQL text which more laconic and it is better read has no relation to high performance. G>> well it there was a second argument: 1. Productivity, 2.  and expressiveness. All the same SQL very powerful he allows you to request that is necessary for you, instead of as  the data. G> Ok, write the request satisfying following conditions: G> 1) If the user the administrator it to show all records G> 2) If the user not the administrator G> - to show it records where the user = author G> - or the author of record is included into group of friends of current user G> - and records should not be hidden G> 3) Records have to be filtered on a category which the user (id selected categories - a query parameter, can be empty) G> Thus request should be as much as possible laconic and fast. I consider - perfectly, practically in a natural language select r.id, r.name from rows as r where r. IsHidden = false and (exists (select * from Administrators a where a. User = r. User) or exist (select * from UserFriends uf where uf. User = r. User and r. Friend = @currentUser))

41

Re: Business of the logician in

Hello, Sinix, you wrote: S> Hello, Gattaka, you wrote: S> Well it works for the code of the healthy person from a box. At us it is for this purpose used  a stack, and it already existed by the time of when I came to a command. That is logic  on the client and on the server at you ? On the server it  from it change tracking, and on the client it  a stack written by the time of when you came to a command? ...

42

Re: Business of the logician in

G> do not trust. , here to you real business the scenario. There is a computer network in which there are network points and users. They have communications among themselves, it is we all we store in basis and we give the chance through our application . G> Tables User (Id, Name, Property), Network_Node (Id, Name, Property), User_User (User1Id, User2Id), Network_Node (Node1Id, Node2Id), UserOnNode (NodeId, UserId) G> In our basis of 70000 nodes on one user on a node (for simplicity). Users are connected all to all. For some (approximately half) nodes sign Prorepry has been put down - now it is necessary to add for such nodes on which there are  the bound users. Especially count the size of table User_User, it is the pleasant moment very similar on  the task which dares at  migrations. And there  what yes as. Will be normal SQL.

43

Re: Business of the logician in

Hello, HeBpuMHeCkaTuHa, you wrote: G>> do not trust. , here to you real business the scenario. There is a computer network in which there are network points and users. They have communications among themselves, it is we all we store in basis and we give the chance through our application . G>> Tables User (Id, Name, Property), Network_Node (Id, Name, Property), User_User (User1Id, User2Id), Network_Node (Node1Id, Node2Id), UserOnNode (NodeId, UserId) G>> In our basis of 70000 nodes on one user on a node (for simplicity). Users are connected all to all. For some (approximately half) nodes sign Prorepry has been put down - now it is necessary to add for such nodes on which there are  the bound users. Especially count the size of table User_User, it is pleasant moment HBM> very similar on  the task which dares at  migrations. And there  what yes as. Will be normal SQL. That for  the task. Sign  - will be deleted, in it an administration and system essence.  together with a sign and communications walk... This requirement of business.

44

Re: Business of the logician in

Hello, Gattaka, you wrote: HBM>> who hinders to pull out only that data which needs and be not to dragged the superfluous? G>  hinders. At me, we admit  the table on essence, and from this essence it is necessary for steam of columns for the report.  all essence pulls out and further you will work with that field that is necessary for you.  NET (EF) it is possible to create anonymous type and which to specify the necessary properties/fields. The request pulls out only them. For example, if is in EF essence of a type public class SomeEntity {public int Id {get; set;} public string Name {get; set;} public string Data {get; set;} public float Code {get; set;}} then request context. SomeEntities.Select (x => new x. Id x. Code}).FirstOrDefault (); turns in SELECT TOP (1) [c]. [Id] AS [Id], [c]. [Code] AS [Code] FROM [dbo]. [SomeEntities] AS [c] go

45

Re: Business of the logician in

Hello, gandjustas, you wrote: G> It is the person following the approach "then it is optimizable" wrote instead of advanced query pair foreach cycles. That Mahlo that received select n+1 so also the representation code was guided by objects of model, each of which demanded a raising on some KB of the text. As a result navigation was under construction half-seconds. Not "preliminary optimization" since at once it was visible that the code does not pull it. Moreover "and then a cache we add" it generally a frank sentence initially to be guided by a crutch. So it is simple the justification of the bad code motive "well all know about harm of premature optimization". I suggest to consider that it is an example of that it is impossible to write the fig code, being covered with the thesis about premature optimization.

46

Re: Business of the logician in

Hello, Gattaka, you wrote: S>> Well it works for the code of the healthy person from a box. At us it is for this purpose used  a stack, and it already existed by the time of when I came to a command. G> that is logic  on the client and on the server at you ? On the server it  from it change tracking, and on the client it  a stack written by the time of when you came to a command? ... Well the pancake, asked about , do an output about  Duplications is not present - nobody forbade reusage of the code

47

Re: Business of the logician in

Hello, Doc, you wrote: Doc> Hello, Gattaka, you wrote: It is all fine, but only the difference between such usage  and writing of requests on SQL is reduced to that what language we use. Well upon C# since many do not know plainly SQL. Essence  after all not in it. Idea such that we work with our domain objects as usual as if databases are not present. These domain objects  in itself the data and methods on their handling, business to the logician. If I am necessary these domain entities not only on the server I can use, but also on the client, yes anywhere. Since they do not depend on a DB, from  and something else. And here saving and  objects from a DB incurs  and if it is sufficient clever - all apprx.

48

Re: Business of the logician in

Hello, Gattaka, you wrote: G> Hello, gandjustas, you wrote: G>> Vykini NHibernate, take EF or linq2db, there there are no such problems. G> you will be , but we threw out before EF. There was a painful passage on NH... At EF too a heap of lacks, for example it is not allowed to receive to you pure domain objects. That is in classes of domain entities at you  links to types from EF, and it is not correct. I, for example, should use freely domain essence on the client without dragging there ORM... And requests at EF it is simple  some, NH in this plan it is better, though too . Here it is necessary to understand in the history: the compiler Command let out linq2sql to justify presence Expression Trees in C#. As guys in a compiler command very abrupt and from library it turned out very abrupt. Thus as well as all compiler -  not expanded. Plans for long-term development linq2sql was not. Parallely  dudes from a command sql server programmability took to nobody necessary, recomplicated  object spaces and stretched on it linq. It turned out EF. He plainly was able nothing, demanded to be inherited from the classes and had strange enough dial-up of possibilities. To the version.NET 4.0 in linq2sql corrected pair of bugs, but more happened nothing, EF too refined (ef4) a little, made at least exterior include in entities, corrected a little linq the provider. But all the same ef4 was a shit. After that, in 2012, ef gave to a command asp.net. ASP.NET the command very abrupt, solves real problems, instead of invents . First of all they over crappy EF wrote code first and migrations, from this point on generally became possible to use EF (ef5). Then got rid from EDM and on a maximum threw out a heavy heritage object spaces (unfortunately not completely), it turned out quite worthy ORM (ef6). B the most important thing was laid out by all source codes in , appeared   extensions. Now decided to throw out final old EF, left only code first api, for the provider used  relinq (which by the way uses and NHibernate). It is called EF7 or EFCore. The heap of lacks about which you write is in EF4. And if to take necessary  bases of everyone  already now it is possible EFCore. G> do not trust. , here to you real business the scenario. There is a computer network in which there are network points and users. They have communications among themselves, it is we all we store in basis and we give the chance through our application . G> Tables User (Id, Name, Property), Network_Node (Id, Name, Property), User_User (User1Id, User2Id), Network_Node (Node1Id, Node2Id), UserOnNode (NodeId, UserId) G> In our basis of 70000 nodes on one user on a node (for simplicity). Users are connected all to all. For some (approximately half) nodes sign Prorepry has been put down - now it is necessary to add for such nodes on which there are  the bound users. Especially count the size of table User_User, it is the pleasant moment And what task it is necessary to solve? G>>>> the SQL text which more laconic also is better read has no relation to high performance. G>>> well it there was a second argument: 1. Productivity, 2.  and expressiveness. All the same SQL very powerful he allows you to request that is necessary for you, instead of as  the data. G>> Ok, write the request satisfying following conditions: G>> 1) If the user the administrator it to show all records G>> 2) If the user not the administrator G>> - to show it records where the user = author G>> - or the author of record is included into group of friends of current user G>> - and records should not be hidden G>> 3) Records have to be filtered on a category which the user (id selected categories - a query parameter, can be empty) G>> Thus request should be as much as possible laconic and fast. G> I consider - perfectly, practically in natural language G> G> select r.id, r.name G> from rows as r G> where r. IsHidden = false and G> (exists (select * from Administrators a where a. User = r. User) or G> exist (select * from UserFriends uf where uf. User = r. User and r. Friend = @currentUser)) G> 1) the Filter on a category forgot 2) the Filter on the author of a post forgot 3) the Filter on managers incorrect, should be the current user the administrator, instead of the author the Most important thing even in such type basis does not construct the optimal plan and request will be fulfilled badly. The correct approach - to make 4 requests: 1) For the administrator without  2) For the administrator with the filter 3) For the normal user without the filter 4) For the normal user with the filter These 4 request will work better any one which you will write. And with linq it leads only to two if in the logician of the program.

49

Re: Business of the logician in

Hello, Doc, you wrote: Doc> Hello, gandjustas, you wrote: G>> It is the person following the approach "then it is optimizable" wrote instead of advanced query pair foreach cycles. That Mahlo that received select n+1 so also the representation code was guided by objects of model, each of which demanded a raising on some KB of the text. As a result navigation was under construction half-seconds. Doc> not "preliminary optimization" since at once it was visible that the code does not pull it. Moreover "and then a cache we add" it generally a frank sentence initially to be guided by a crutch. So it is simple the justification of the bad code motive "well all know about harm of premature optimization". Doc> I Suggest to consider that it is an example of that it is impossible to write the fig code, being covered with the thesis about premature optimization. It indeed. But it is well visible in a retrospective show. And how you will prove in each specific case, what it is simply fig code, instead of attempt of "premature optimization", without knowing to what consequences it results? Even in this subject judgements that it is possible to write aby-what sql are expressed, and then to "optimize". It is impossible Though in most cases to "optimize", it is necessary to rewrite, and it is strong.

50

Re: Business of the logician in

Hello, gandjustas, you wrote: G>> do not trust. , here to you real business the scenario. There is a computer network in which there are network points and users. They have communications among themselves, it is we all we store in basis and we give the chance through our application . G>> Tables User (Id, Name, Property), Network_Node (Id, Name, Property), User_User (User1Id, User2Id), Network_Node (Node1Id, Node2Id), UserOnNode (NodeId, UserId) G>> In our basis of 70000 nodes on one user on a node (for simplicity). Users are connected all to all. For some (approximately half) nodes  sign Prorepry = true has been put down. Now it is necessary to add communications for such nodes (For nodes which have  the bound users). Especially count the size of table User_User, it is pleasant moment G> And what task should be solved?  the description also selected that it is necessary to make. What tell? It is necessary to explain still?